Welcome to the case study!

Python Toolbox

Hugo Bowne-Anderson

Data Scientist at DataCamp

World bank data

  • Data on world economies for over half a century
  • Indicators
    • Population
    • Electricity consumption
    • CO2 emissions
    • Literacy rates
    • Unemployment
    • Mortality rates
Python Toolbox

Using zip()

avengers = ['hawkeye', 'iron man', 'thor', 'quicksilver']
names = ['barton', 'stark', 'odinson', 'maximoff']

z = zip(avengers, names)
print(type(z))
<class 'zip'>
print(list(z))
[('hawkeye', 'barton'), ('iron man', 'stark'), 
('thor', 'odinson'), ('quicksilver', 'maximoff')]
Python Toolbox

Defining a function

  • raise.py
def raise_both(value1, value2):
    """Raise value1 to the power of value2
    and vice versa."""
    new_value1 = value1 ** value2
    new_value2 = value2 ** value1
    new_tuple = (new_value1, new_value2)
    return new_tuple
Python Toolbox

Re-cap: list comprehensions

Basic

[output expression for iterator variable in iterable]

Advanced

[output expression + 
conditional on output for iterator variable in iterable +
conditional on iterable]
Python Toolbox

Let's practice!

Python Toolbox

Preparing Video For Download...