GithubHelp home page GithubHelp logo

nicklope / u4_lab_python_tuple_exercise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sei-r-2-22/u4_lab_python_tuple_exercise

0.0 0.0 0.0 3 KB

In this lab, we'll go through several exercises to become comfortable with using tuples.

u4_lab_python_tuple_exercise's Introduction

Python Containers - Lab

Getting Started

  • Fork and Clone

Setup

Create a main.py and test your code with python3 main.py.

Exercises

Exercise 1

  • Create a list named students containing some student names (strings).
  • Print out the second student's name.
  • Print out the last student's name.

Exercise 2

  • Create a tuple named foods containing the same number of foods (strings) as there are names in the students list.
  • Use a for loop to print out the string "food goes here is a good food".

Exercise 3

  • Using a for loop, print just the last two food strings from foods.

Exercise 4

  • Create a dictionary named home_town containing the keys of city, state and population.
  • Print a string with this format:
    "I was born in city, state - population of population"

Exercise 5

  • Iterate over the key: value pairs in home_town and print a string for each item, for example:
    "city = Arcadia"
    "state = California"
    "population = 58000"

Exercise 6

  • Create an empty list named cohort.

  • Using a for loop, add one dictionary to the cohort list for each student name. Each dictionary should have this shape:

     {
       'student': 'Tina',
       'fav_food' 'Cheeseburger'
     }
  • Iterate over cohort printing out each element.

Exercise 7

  • Using the list of students and list comprehension, assign to a variable named awesome_students a new list containing strings similar to this:
    ["Tina is awesome!", "Fred is awesome!", "Wilma is awesome!"]
  • Iterate over awesome_students printing out each string.

Exercise 8

  • Using the tuple foods and list comprehension within a for loop, print each food string that contains the letter a.

u4_lab_python_tuple_exercise's People

Contributors

ahonore42 avatar anpato 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.