From d3e7874710c9aa082cb4b809fc4ea63df1492d53 Mon Sep 17 00:00:00 2001 From: Jeet Upadhyay <82926740+jeet200@users.noreply.github.com> Date: Sat, 31 Jan 2026 08:38:30 +0530 Subject: [PATCH 1/2] Add conditional statements for grade evaluation --- 3-control-flow/12_grades.py | 4 ++++ 1 file changed, 4 insertions(+) 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") From a90a45c03661a758f453bff6d0da47a1ff2a0156 Mon Sep 17 00:00:00 2001 From: Jeet Upadhyay <82926740+jeet200@users.noreply.github.com> Date: Mon, 2 Feb 2026 07:24:03 +0530 Subject: [PATCH 2/2] Refactor fortune function to use random.choice Updated the fortune function to use random.choice for selecting fortunes from a list. --- 6-functions/29_fortune_cookie_1.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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()