Giter Club home page Giter Club logo

ds-learn-interview-2-interview-pt2-000's Introduction

Jupyter notebooks

You can type text or code! These blocks execute things.

# Press SHIFT + ENTER to run this cell!

print("It Worked!")

Introduction to data structures

We want to figure out where we want to go for dinner tonight. And we are craving hamburgers :).

This leads us to a first data structure: a string

In the cell below, create and print a string called "mcdonalds"

restaurant_1 = 
print(restaurant)

Use the capitalize() method to capitalize the contents of our restaurant variable. Print the variable again to see our changes!

restaurant_1 = 
print(restaurant)

1. Lists

We want to collect our data. A list is an ordered collection. You can use square brackets to create a list. You can use

  • the original strings
  • the stored variables
restaurant_2 = 
restaurants = 
same_restaurants = 

Note that these two are exactly the same! You can test for this:

restaurants == same_restaurants

What if we want to access information inside restaurants or same_restaurants?

What if you want to add a burger restaurant to your list? Append 'Shake Shack' to restaurants

# Append "Shake Shack" to restaurants!

print(restaurants)

2. Dictionaries

Maybe we want to save attributes for our restaurants? Lists are not very useful here.

mcdonalds = {'name':'mcdonalds', 'address': "85 broad street"}

Why not a list? Dictionaries have keys and values.

mcdonalds.keys()
mcdonalds.values()

You can wrap this into a list

list(mcdonalds.values())

Create two more restaurant dictionaries for the following restaurants:

Restaurant Address
Burger King 1313 Broadway
Shake Shack 691 8th Ave

Now use the correct key to access the address for Shake Shack:

Now, we'll set up for the final programming challenge of this lesson.

First, create a list containing the restaurant dictionaries we made above.

list_of_dictionaries = 

Challenge

In the cell below, iterate through our list of dictionaries, and print out "{Restaurant Name} is located at {Restaurant Address}!" for each restaurant.

Your output should be:

"mcdonalds is located at 85 broad street!"
"Burger King is located at 1313 broadway!"
"Shake Shack is located at 691 8th Ave!"

ds-learn-interview-2-interview-pt2-000's People

Contributors

loredirick avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.