2 + 2
myvar = "this is a string"
print(myvar)
myvar = "this is not a string"
myvar2 = 8
print(myvar2)
print("this is not a string")
print(myvar)
print(this is not a string)
temp_C = 50
temp_C * 9 / 5 + 32
temp_C + 20
# Prints only last line result
temp_C = 50
temp_F = temp_C * 9 / 5 + 32
print(temp_F) # Print a value that we previously assigned
# Checkpoint 1
x = 1
y = 2
# Swap the values of x and y (hint: use a third variable)
#x, y = y, x
z = x
a = y
x = a
y = z
print(x)
print(y)
chemist = "Linus Pauling"
print(chemist)
chemist[0:5]
chemist[0]
chemist[1]
first_value = "initial"
second_value = first_value[1:5]
first_value = second_value[2]
print(first_value)
physicist = "Max Planck"
len(physicist)
length = len(physicist)
physicist[length - 1]
physicist[2:length]
physicist[2:]
physicist[:3]
type(temp_C)
type(physicist)
chemist + physicist
chemist + temp_C
8 / 3
type(8 / 3)
temp_C + (8 / 3)
type(temp_F)
"(" + str(temp_F) + ")"
type(10)
float(10)
int(10.999)
# print, len, type, str, int, float
print()
print
max(1, 5, 3)
help(max)
planck_length = len(physicist)
output = print("a string")
print(output)
type(output)
mean(1, 4, 5)
import math
dir(math)
import stat
htam = math
# Checkpoint
radiance = 1.0
radiance = max(2.1, 2.0 + min(radiance, radiance - 0.5))
# What is the order of operations?
# What is the final value of radiance?
print(radiance)
import pandas
europe = pandas.read_csv("gapminder_gdp_europe.csv")
europe.mean()
europe.std()
pandas.read_csv
europe = pandas.read_csv("gapminder_gdp_europe.csv",
index_col="country")
europe.head()
europe.gdpPercap_1952.Austria
Austria
europe.loc['Austria']
europe.loc['Austria'].mean()
europe.columns
europe.gdpPercap_1952 + europe.gdpPercap_1957
gdp_1952_and_1957 = europe['gdpPercap_1952'] + europe['gdpPercap_1957']
gdp_1952_and_1957.mean()
import matplotlib.pyplot
%matplotlib inline
matplotlib.pyplot.hist(europe.gdpPercap_1952)
matplotlib.pyplot.hist(europe.gdpPercap_1952, bins=20)
europe.loc['Switzerland']
import matplotlib.pyplot as plt
plt.hist(europe.gdpPercap_1952, bins=20, alpha=0.5, label='1952')
plt.hist(europe.gdpPercap_1957, bins=20, alpha=0.5, label='1957')
plt.xlabel('GDP Per-capita (US$2007)')
plt.ylabel('Count')
plt.legend()
plt.title("Economic shifts in post-war Europe")
print()
europe.loc['Switzerland']
#years = [1952, 1957, 1962, 1967,
# 1972, 1977, 1982, 1987,
# 1992, 1997, 2002, 2007]
years = [int(year) for year in europe.columns.str[-4:]]
plt.scatter(years, europe.loc['Switzerland'])
plt.plot(years, europe.T, label='Switzerland')
#plt.plot(years, europe.loc['France'], label='France')
print()