diff --git a/3-control-flow/12_grades.py b/3-control-flow/12_grades.py index ff14170..8f5618e 100644 --- a/3-control-flow/12_grades.py +++ b/3-control-flow/12_grades.py @@ -3,7 +3,11 @@ grade = 58 +#First Way if grade >= 55: print('You passed.') else: print('You failed.') + +#Second Way +print("You Passed" if grade >= 55 else "You Failed") diff --git a/6-functions/29_fortune_cookie_1.py b/6-functions/29_fortune_cookie_1.py index d82687b..999d752 100644 --- a/6-functions/29_fortune_cookie_1.py +++ b/6-functions/29_fortune_cookie_1.py @@ -21,4 +21,27 @@ def fortune(): fortune() fortune() -fortune() \ No newline at end of file +fortune() + +# Upadted Version + +import random + +options = [ + 'Don’t pursue happiness – create it.', + 'All things are difficult before they are easy.', + 'The early bird gets the worm, but the second mouse gets the cheese.', + 'If you eat something and nobody sees you eat it, it has no calories.', + 'Someone in your life needs a letter from you.', + 'Don’t just think. Act!', + 'Your heart will skip a beat.', + 'The fortune you search for is in another cookie.', + 'Help! I’m being held prisoner in a Chinese bakery!' +] + +def fortune(): + print(random.choice(options)) #No need to gen Random int as python can choose by itself + +fortune() +fortune() +fortune()