# 8-2
def favorite_book(title):
print('One of my favorite book is ' + title)
title_temp = input("What's your favorite book?")
favorite_book(title_temp)
# 8-5
def describe_city(city,country='China'):
print(city + ' is in ' + country)
describe_city('Shanghai')
describe_city('Beijing')
describe_city('New York','USA')
# 8-7
def make_album(name,album):
albums = {name : album}
return albums
album_temp = make_album('Alice','1')
print(album_temp)
album_temp = make_album('Bob','2')
print(album_temp)
album_temp = make_album('Carol','3')
print(album_temp)
# 8-9
magicians = ['Alice' , 'Bob' , 'Carol']
def show_magicians(magicians):
for magician in magicians:
print(magician)
show_magicians(magicians)
# 8-14
def make_car(productor,versions,**msg):
cars = {}
cars['productor'] = productor
cars['versions'] = versions
for key,value in msg.items():
cars[key] = value
return cars
car = make_car('subaru', 'outbreak', color='blue', tow_package=True)
print(car)
# 8-16
hello_world.py
def print_hello_world():
print('Hello world.')
import.py
import hello_world
hello_world.print_hello_world()
from hello_world import print_hello_world
print_hello_world()
from hello_world import print_hello_world as phw
phw()
import hello_world as hw
hw.print_hello_world()
from hello_world import *
print_hello_world()