Skip to content

Latest commit

 

History

History
92 lines (52 loc) · 2.48 KB

05a-python.md

File metadata and controls

92 lines (52 loc) · 2.48 KB

Learn Python

Read Allen Downey's Think Python for getting up to speed with Python 2.7 and computer science topics. It's completely available online, or you can buy a physical copy if you would like.

For quick and easy interactive practice with Python, many people enjoy Codecademy's Python track. There's also Learn Python The Hard Way and The Python Tutorial.


Q1. Lists & Tuples

How are Python lists and tuples similar and different? Which will work as keys in dictionaries? Why?

REPLACE THIS TEXT WITH YOUR RESPONSE


Q2. Lists & Sets

How are Python lists and sets similar and different? Give examples of using both. How does performance compare between lists and sets for finding an element. Why?

REPLACE THIS TEXT WITH YOUR RESPONSE


Q3. Lambda Function

Describe Python's lambda. What is it, and what is it used for? Give at least one example, including an example of using a lambda in the key argument to sorted.

REPLACE THIS TEXT WITH YOUR RESPONSE


Q4. List Comprehension, Map & Filter

Explain list comprehensions. Give examples and show equivalents with map and filter. How do their capabilities compare? Also demonstrate set comprehensions and dictionary comprehensions.

REPLACE THIS TEXT WITH YOUR RESPONSE


Complete the following problems by editing the files below:

Q5. Datetime

Use Python to compute days between start and stop date.
a.

date_start = '01-02-2013'    
date_stop = '07-28-2015'

REPLACE THIS TEXT WITH YOUR RESPONSE (answer will be in number of days)

b.

date_start = '12312013'  
date_stop = '05282015'  

REPLACE THIS TEXT WITH YOUR RESPONSE (answer will be in number of days)

c.

date_start = '15-Jan-1994'      
date_stop = '14-Jul-2015'  

REPLACE THIS TEXT WITH YOUR RESPONSE (answer will be in number of days)

Place code in this file: q5_datetime.py


Q6. Strings

Edit the 7 functions in q6_strings.py


Q7. Lists

Edit the 5 functions in q7_lists.py


Q8. Parsing

Write a script as indicated (using the football data) in q8_parsing.py