Created
November 30, 2015 14:39
-
-
Save liuderchi/e8c2e761c5204b95100d to your computer and use it in GitHub Desktop.
wk2-python-review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def umbrella_check( p ): | |
if p > 50: | |
print 'remember your umbrella' | |
else: | |
print 'no need umbrella' | |
umbrella_check( 30 ) #no need umbrella | |
umbrella_check( 51 ) #remember your umbrella | |
def good_umbrella_check( p ): | |
if p > 50: | |
if p == 100: | |
print 'remember umbrella and raincoat' | |
else: | |
print 'remember your umbrella' | |
else: | |
print 'no need umbrella' | |
good_umbrella_check( 50 ) #no need umbrella | |
good_umbrella_check( 99 ) #remember your umbrella | |
good_umbrella_check( 100 ) #remember umbrella and raincoat | |
def rank( score ): | |
'''adv''' | |
weekdays = ['Mon','Tue','Wed','Thu','Fri'] | |
def print_weekday( num, li ): | |
print li[ num - 1 ] | |
print_weekday( 3 , weekdays ) #Wed | |
#aprint_weekday( 6 , li) | |
weekdays = ['Mon','Tue','Wed','Thu','Fri'] | |
def good_print_weekday( num, weekdays ): | |
if num > 5: | |
print 'index too large' | |
else: | |
print weekdays[ num - 1] | |
good_print_weekday( 2, weekdays ) #Tue | |
good_print_weekday( 7, weekdays ) #index too large | |
def print_burger(): | |
menu = ['Big Mac', 'Filet-O-Fish', 'McChicken' , 'Double Cheese', 'Grilled Chicken Burger'] | |
print menu[0] | |
print menu[1] | |
print menu[2] | |
print menu[3] | |
print menu[4] | |
print_burger() | |
#Big Mac | |
#Filet-O-Fish | |
#McChicken | |
#Double Cheese | |
#Grilled Chicken Burger | |
def good_print_burger(): | |
menu = ['Big Mac', 'Filet-O-Fish', 'McChicken' , 'Double Cheese', 'Grilled Chicken Burger'] | |
i = 0 | |
while i < 5: | |
print menu[i] | |
i = i + 1 | |
good_print_burger() | |
#Big Mac | |
#Filet-O-Fish | |
#McChicken | |
#Double Cheese | |
#Grilled Chicken Burger | |
def forever_hello(): | |
i = 0 | |
while i > -10: | |
print 'hello' | |
#forever_hello() | |
def forever_goodbye(): | |
i = 1 | |
while i != 10: | |
print 'goodbye' | |
i = i + 2 | |
#forever_goodbye() | |
def pour_tea( drip ): | |
all_tea = 0 | |
while all_tea < 80: | |
all_tea = all_tea + drip | |
print all_tea | |
pour_tea( 5 ) #80 | |
pour_tea( 11 ) #88 | |
pour_tea( 22 ) #92 | |
def print_list( schedule ): | |
'''adv''' | |
monday = ['國', '國', '數', '數', '體', '英', '英'] | |
wed = ['美', '美', '自', '自'] | |
print_list( monday ) | |
print_list( wed ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment