From c64f9e9d7e38551be254ceff19925a6ab03b6fc6 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 1 Mar 2023 00:06:44 -0500 Subject: [PATCH 01/73] Update 15_the_cyclone_1.py --- 3-control-flow/15_the_cyclone_1.py | 1 - 1 file changed, 1 deletion(-) diff --git a/3-control-flow/15_the_cyclone_1.py b/3-control-flow/15_the_cyclone_1.py index 9c46e2e..6fc44b5 100644 --- a/3-control-flow/15_the_cyclone_1.py +++ b/3-control-flow/15_the_cyclone_1.py @@ -3,7 +3,6 @@ height = 250 credits = 10 -with_taller_person = False if height >= 137 and credits >= 10: print("Enjoy the ride!") From 02f99003f6d0a306a0a9ebab593227800cb9cfdf Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Wed, 1 Mar 2023 00:11:57 -0500 Subject: [PATCH 02/73] Update 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 90ae509..f90f043 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -7,12 +7,12 @@ if height >= 137 and credits >= 10: print("Enjoy the ride!") - -if height < 137: +elif height < 137: if height < 100 or not with_taller_person: print("You're not tall enough for this ride yet.") elif height >= 100 and with_taller_person: print("Enjoy the ride!") - -if credits < 10: - print("You don't have enough credits to ride.") \ No newline at end of file +elif credits < 10: + print("You don't have enough credits to ride.") +else: + print("Invalid data.") From 9e408c9927f3d6dfdde687c882d38d3a892985ed Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Fri, 3 Mar 2023 21:22:24 -0500 Subject: [PATCH 03/73] Solutions for challenges 39 & 40 (TLoP) --- 8-modules/39_slot_machine.py | 31 +++++++++++++++++++++++++++++++ 8-modules/40_birthday_card.py | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 8-modules/39_slot_machine.py create mode 100644 8-modules/40_birthday_card.py diff --git a/8-modules/39_slot_machine.py b/8-modules/39_slot_machine.py new file mode 100644 index 0000000..0da3105 --- /dev/null +++ b/8-modules/39_slot_machine.py @@ -0,0 +1,31 @@ +# Slot Machine 🎰 +# Codédex + +import random + +slot_machine_symbols = [ + '🍒', + '🍇', + '🍉', + '7️⃣' +] + +def play_slots(): + results = random.choices(slot_machine_symbols, k=3) + all_sevens = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' + + while not all_sevens: + print(f'{results[0]} | {results[1]} | {results[2]}') + all_sevens = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' + + if all_sevens: + print("Jackpot!!! 💰") + else: + results = random.choices(slot_machine_symbols, k=3) +answer = "Y" + +while answer.upper() != "N": + play_slots() + answer = input("Keep playing? (Y/N) ") + +print("Thanks for playing!") \ No newline at end of file diff --git a/8-modules/40_birthday_card.py b/8-modules/40_birthday_card.py new file mode 100644 index 0000000..30b93e9 --- /dev/null +++ b/8-modules/40_birthday_card.py @@ -0,0 +1,21 @@ +# Birthday Card 🎂 +# Codédex + +import random, datetime + +bday_messages = [ + 'Hope you have a very Happy Birthday! 🎈', + 'It\'s your special day – get out there and celebrate!', + 'You were born and the world got better – everybody wins! Happy Birthday!' +] + +today = datetime.date.today() + +my_birthday = datetime.date(2023, 4, 5) + +days_away = my_birthday - today + +if my_birthday == today: + print(random.choice(bday_messages)) +else: + print(f'My birthday is {days_away} away!') \ No newline at end of file From e4fe522f04a5c472f5c4a6d468ee73ce21f840de Mon Sep 17 00:00:00 2001 From: vance Date: Fri, 10 Mar 2023 18:11:55 -0500 Subject: [PATCH 04/73] Fix issue #29 in The Cyclone Reorder lines so that `credits` gets checked before `height`, to resolve https://github.com/codedex-io/python-101/issues/29 . Note that this does alter output in cases where credits and height are both too small, so a different fix might be preferred. --- 3-control-flow/15_the_cyclone_2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index f90f043..efc8ae7 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -7,12 +7,12 @@ if height >= 137 and credits >= 10: print("Enjoy the ride!") +elif credits < 10: + print("You don't have enough credits to ride.") elif height < 137: if height < 100 or not with_taller_person: print("You're not tall enough for this ride yet.") elif height >= 100 and with_taller_person: print("Enjoy the ride!") -elif credits < 10: - print("You don't have enough credits to ride.") else: print("Invalid data.") From 6f33c406dc82edae47214c3d3eb65352fdd5a491 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Fri, 10 Mar 2023 21:00:37 -0500 Subject: [PATCH 05/73] Update solution #2 for Cyclone challenge --- 3-control-flow/15_the_cyclone_2.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index f90f043..2eccafc 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -5,14 +5,15 @@ credits = 10 with_taller_person = False -if height >= 137 and credits >= 10: - print("Enjoy the ride!") -elif height < 137: - if height < 100 or not with_taller_person: - print("You're not tall enough for this ride yet.") - elif height >= 100 and with_taller_person: - print("Enjoy the ride!") -elif credits < 10: +if credits < 10: print("You don't have enough credits to ride.") else: - print("Invalid data.") + if height >= 137 and credits >= 10: + print("Enjoy the ride!") + elif height < 137: + if height < 100 or not with_taller_person: + print("You're not tall enough for this ride yet.") + elif height >= 100 and with_taller_person: + print("Enjoy the ride, folks!") + else: + print("Invalid data.") From b3ea86eb2c8228de9965151480d807c5fe2b66b5 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Sat, 11 Mar 2023 12:58:50 -0500 Subject: [PATCH 06/73] revert solution #2 for The Cyclone --- 3-control-flow/15_the_cyclone_2.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 2eccafc..a753545 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -5,15 +5,14 @@ credits = 10 with_taller_person = False +if height >= 137 and credits >= 10: + print("Enjoy the ride!") + +if height < 137: + if height < 100 or not with_taller_person: + print("You're not tall enough for this ride yet.") + elif height >= 100 and with_taller_person: + print("Enjoy the ride!") + if credits < 10: print("You don't have enough credits to ride.") -else: - if height >= 137 and credits >= 10: - print("Enjoy the ride!") - elif height < 137: - if height < 100 or not with_taller_person: - print("You're not tall enough for this ride yet.") - elif height >= 100 and with_taller_person: - print("Enjoy the ride, folks!") - else: - print("Invalid data.") From 524599143c0408da581a496da68ebce7e5e3316a Mon Sep 17 00:00:00 2001 From: Goku-kun Date: Sat, 11 Mar 2023 23:33:43 +0530 Subject: [PATCH 07/73] Update: revert to previous solution version for \#2 The Cyclone --- 3-control-flow/15_the_cyclone_2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index a753545..f90f043 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -7,12 +7,12 @@ if height >= 137 and credits >= 10: print("Enjoy the ride!") - -if height < 137: +elif height < 137: if height < 100 or not with_taller_person: print("You're not tall enough for this ride yet.") elif height >= 100 and with_taller_person: print("Enjoy the ride!") - -if credits < 10: +elif credits < 10: print("You don't have enough credits to ride.") +else: + print("Invalid data.") From b289e8b03f773a89e8ddb21aa29420bd7813484a Mon Sep 17 00:00:00 2001 From: vance Date: Sun, 12 Mar 2023 00:51:53 -0500 Subject: [PATCH 08/73] Update 3-control-flow/15_the_cyclone_2.py Move check for `credits` to the start of the control flow Co-authored-by: Brandon Dusch --- 3-control-flow/15_the_cyclone_2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index efc8ae7..112f9ee 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -5,10 +5,10 @@ credits = 10 with_taller_person = False -if height >= 137 and credits >= 10: - print("Enjoy the ride!") -elif credits < 10: +if credits < 10: print("You don't have enough credits to ride.") +elif height >= 137 and credits >= 10: + print("Enjoy the ride!") elif height < 137: if height < 100 or not with_taller_person: print("You're not tall enough for this ride yet.") From a8222668ec91920ffe7949b67fa93a31358ad804 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Sun, 12 Mar 2023 14:14:06 -0400 Subject: [PATCH 09/73] Update 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 112f9ee..823d034 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -13,6 +13,6 @@ if height < 100 or not with_taller_person: print("You're not tall enough for this ride yet.") elif height >= 100 and with_taller_person: - print("Enjoy the ride!") + print("Enjoy the ride, folks!") else: print("Invalid data.") From 8f58e8eecb7fce5bc9d56c64684149487663ed25 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Tue, 14 Mar 2023 11:48:50 -0400 Subject: [PATCH 10/73] New solutions: Python Ch. 8 --- 8-modules/39_slot_machine.py | 21 +++++++++++---------- 8-modules/40_birthday_card.py | 13 +++++++------ 8-modules/41_solar_system.py | 33 +++++++++++++++++++++++++++++++++ 8-modules/42_forty_two.py | 6 ++++++ 8-modules/43_zen.py | 26 ++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 8-modules/41_solar_system.py create mode 100644 8-modules/42_forty_two.py create mode 100644 8-modules/43_zen.py diff --git a/8-modules/39_slot_machine.py b/8-modules/39_slot_machine.py index 0da3105..bd15797 100644 --- a/8-modules/39_slot_machine.py +++ b/8-modules/39_slot_machine.py @@ -3,29 +3,30 @@ import random -slot_machine_symbols = [ +symbols = [ '🍒', '🍇', '🍉', '7️⃣' ] -def play_slots(): - results = random.choices(slot_machine_symbols, k=3) - all_sevens = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' +def play(): + results = random.choices(symbols, k=3) + win = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' - while not all_sevens: + for i in range(50): print(f'{results[0]} | {results[1]} | {results[2]}') - all_sevens = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' + win = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' - if all_sevens: + if win: print("Jackpot!!! 💰") + break else: - results = random.choices(slot_machine_symbols, k=3) -answer = "Y" + results = random.choices(symbols, k=3) +answer = "Y" while answer.upper() != "N": - play_slots() + play() answer = input("Keep playing? (Y/N) ") print("Thanks for playing!") \ No newline at end of file diff --git a/8-modules/40_birthday_card.py b/8-modules/40_birthday_card.py index 30b93e9..53bdb45 100644 --- a/8-modules/40_birthday_card.py +++ b/8-modules/40_birthday_card.py @@ -6,16 +6,17 @@ bday_messages = [ 'Hope you have a very Happy Birthday! 🎈', 'It\'s your special day – get out there and celebrate!', - 'You were born and the world got better – everybody wins! Happy Birthday!' + 'You were born and the world got better – everybody wins! Happy Birthday!', + 'Another year of you going around the sun! 🌞' ] today = datetime.date.today() -my_birthday = datetime.date(2023, 4, 5) +my_next_birthday = datetime.date(2023, 4, 5) -days_away = my_birthday - today +days_away = my_next_birthday - today -if my_birthday == today: - print(random.choice(bday_messages)) +if my_next_birthday == today: + print(random.choice(bday_messages)) else: - print(f'My birthday is {days_away} away!') \ No newline at end of file + print(f'My next birthday is {days_away} away!') \ No newline at end of file diff --git a/8-modules/41_solar_system.py b/8-modules/41_solar_system.py new file mode 100644 index 0000000..51693eb --- /dev/null +++ b/8-modules/41_solar_system.py @@ -0,0 +1,33 @@ +# Solar System 🪐 +# Codédex + +from math import pi +from random import choice as ch + +planets = [ + 'Mercury', + 'Venus', + 'Earth', + 'Mars', + 'Saturn' +] + +random_planet = ch(planets) +radius = 0 + +if random_planet == 'Mercury': + radius = 2440 +elif random_planet == 'Venus': + radius = 6052 +elif random_planet == 'Earth': + radius = 6371 +elif random_planet == 'Mars': + radius = 3390 +elif random_planet == 'Saturn': + radius = 58232 +else: + print('Oops! An error occurred.') + +planet_area = 4 * pi * radius * radius + +print(f'Area of {random_planet}: {planet_area} km2') \ No newline at end of file diff --git a/8-modules/42_forty_two.py b/8-modules/42_forty_two.py new file mode 100644 index 0000000..7e5928e --- /dev/null +++ b/8-modules/42_forty_two.py @@ -0,0 +1,6 @@ +# Forty Two 4️⃣2️⃣ +# Codédex + +import wikipedia + +print(wikipedia.search('Philosophy of life')) \ No newline at end of file diff --git a/8-modules/43_zen.py b/8-modules/43_zen.py new file mode 100644 index 0000000..d107fc0 --- /dev/null +++ b/8-modules/43_zen.py @@ -0,0 +1,26 @@ +# Zen of Python 🐍 +# Codédex + +import this + +""" +Beautiful is better than ugly. +Explicit is better than implicit. +Simple is better than complex. +Complex is better than complicated. +Flat is better than nested. +Sparse is better than dense. +Readability counts. +Special cases aren't special enough to break the rules. +Although practicality beats purity. +Errors should never pass silently. +Unless explicitly silenced. +In the face of ambiguity, refuse the temptation to guess. +There should be one-- and preferably only one --obvious way to do it. +Although that way may not be obvious at first unless you're Dutch. +Now is better than never. +Although never is often better than *right* now. +If the implementation is hard to explain, it's a bad idea. +If the implementation is easy to explain, it may be a good idea. +Namespaces are one honking great idea -- let's do more of those! +""" \ No newline at end of file From 88d7888ce6dfe08e9951ff1d44e960812b49c44c Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Tue, 14 Mar 2023 13:12:58 -0400 Subject: [PATCH 11/73] Update 43_zen.py --- 8-modules/43_zen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/8-modules/43_zen.py b/8-modules/43_zen.py index d107fc0..60c1fe9 100644 --- a/8-modules/43_zen.py +++ b/8-modules/43_zen.py @@ -1,4 +1,4 @@ -# Zen of Python 🐍 +# The Zen of Python 📜 # Codédex import this @@ -23,4 +23,4 @@ If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! -""" \ No newline at end of file +""" From 6ec0cb63a4d5f92063b135e9dc079f15ebd8feb9 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Wed, 15 Mar 2023 23:27:04 -0400 Subject: [PATCH 12/73] Update Python Ch. 8 solutions --- 8-modules/39_slot_machine_1.py | 19 ++++++++++++++++ ...9_slot_machine.py => 39_slot_machine_2.py} | 15 ++++++------- 8-modules/40_birthday_card.py | 22 ------------------- ...{41_solar_system.py => 40_solar_system.py} | 3 +-- 8-modules/41_main.py | 16 ++++++++++++++ 8-modules/bday_messages.py | 14 ++++++++++++ 6 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 8-modules/39_slot_machine_1.py rename 8-modules/{39_slot_machine.py => 39_slot_machine_2.py} (54%) delete mode 100644 8-modules/40_birthday_card.py rename 8-modules/{41_solar_system.py => 40_solar_system.py} (90%) create mode 100644 8-modules/41_main.py create mode 100644 8-modules/bday_messages.py diff --git a/8-modules/39_slot_machine_1.py b/8-modules/39_slot_machine_1.py new file mode 100644 index 0000000..d3fd587 --- /dev/null +++ b/8-modules/39_slot_machine_1.py @@ -0,0 +1,19 @@ +# Slot Machine 🎰 +# Codédex + +import random + +symbols = [ + '🍒', + '🍇', + '🍉', + '7️⃣' +] + +results = random.choices(symbols, k=3) +print(f'{results[0]} | {results[1]} | {results[2]}') + +if (results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣'): + print('Jackpot! 💰') +else: + print('Thanks for playing!') \ No newline at end of file diff --git a/8-modules/39_slot_machine.py b/8-modules/39_slot_machine_2.py similarity index 54% rename from 8-modules/39_slot_machine.py rename to 8-modules/39_slot_machine_2.py index bd15797..6b5cb8b 100644 --- a/8-modules/39_slot_machine.py +++ b/8-modules/39_slot_machine_2.py @@ -11,22 +11,21 @@ ] def play(): - results = random.choices(symbols, k=3) - win = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' - for i in range(50): + for i in range(1, 51): + results = random.choices(symbols, k=3) print(f'{results[0]} | {results[1]} | {results[2]}') win = results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣' if win: - print("Jackpot!!! 💰") + print('Jackpot!!! 💰') break else: results = random.choices(symbols, k=3) -answer = "Y" -while answer.upper() != "N": +answer = '' +while answer.upper() != 'N': play() - answer = input("Keep playing? (Y/N) ") + answer = input('Keep playing? (Y/N) ') -print("Thanks for playing!") \ No newline at end of file +print('Thanks for playing!') \ No newline at end of file diff --git a/8-modules/40_birthday_card.py b/8-modules/40_birthday_card.py deleted file mode 100644 index 53bdb45..0000000 --- a/8-modules/40_birthday_card.py +++ /dev/null @@ -1,22 +0,0 @@ -# Birthday Card 🎂 -# Codédex - -import random, datetime - -bday_messages = [ - 'Hope you have a very Happy Birthday! 🎈', - 'It\'s your special day – get out there and celebrate!', - 'You were born and the world got better – everybody wins! Happy Birthday!', - 'Another year of you going around the sun! 🌞' -] - -today = datetime.date.today() - -my_next_birthday = datetime.date(2023, 4, 5) - -days_away = my_next_birthday - today - -if my_next_birthday == today: - print(random.choice(bday_messages)) -else: - print(f'My next birthday is {days_away} away!') \ No newline at end of file diff --git a/8-modules/41_solar_system.py b/8-modules/40_solar_system.py similarity index 90% rename from 8-modules/41_solar_system.py rename to 8-modules/40_solar_system.py index 51693eb..68b5995 100644 --- a/8-modules/41_solar_system.py +++ b/8-modules/40_solar_system.py @@ -1,8 +1,7 @@ # Solar System 🪐 # Codédex -from math import pi -from random import choice as ch +from math import pi; from random import choice as ch planets = [ 'Mercury', diff --git a/8-modules/41_main.py b/8-modules/41_main.py new file mode 100644 index 0000000..fdae76e --- /dev/null +++ b/8-modules/41_main.py @@ -0,0 +1,16 @@ +# Birthday Card 🎂 +# Codédex + +import datetime +import bday_messages + +today = datetime.date.today() + +my_next_birthday = datetime.date(2023, 4, 5) + +days_away = my_next_birthday - today + +if my_next_birthday == today: + print(bday_messages.random_message) +else: + print(f'My next birthday is {days_away} away!') \ No newline at end of file diff --git a/8-modules/bday_messages.py b/8-modules/bday_messages.py new file mode 100644 index 0000000..02659fb --- /dev/null +++ b/8-modules/bday_messages.py @@ -0,0 +1,14 @@ +# Countdown 🎂 +# Codédex + +import random + +bday_messages = [ + 'Hope you have a very Happy Birthday! 🎈', + 'It\'s your special day – get out there and celebrate! 🎉', + 'You were born and the world got better – everybody wins! Happy Birthday! 🥳', + 'Have lots of fun on your special day! 🎂', + 'Another year of you going around the sun! 🌞' +] + +random_message = random.choice(bday_messages) \ No newline at end of file From 1425d28c2cb2414b9a5b9fa9efab216a0d36da04 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Thu, 16 Mar 2023 13:58:58 -0400 Subject: [PATCH 13/73] Update 39_slot_machine_1.py --- 8-modules/39_slot_machine_1.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/8-modules/39_slot_machine_1.py b/8-modules/39_slot_machine_1.py index d3fd587..70fc1fc 100644 --- a/8-modules/39_slot_machine_1.py +++ b/8-modules/39_slot_machine_1.py @@ -4,10 +4,10 @@ import random symbols = [ - '🍒', - '🍇', - '🍉', - '7️⃣' + '🍒', + '🍇', + '🍉', + '7️⃣' ] results = random.choices(symbols, k=3) @@ -16,4 +16,4 @@ if (results[0] == '7️⃣' and results[1] == '7️⃣' and results[2] == '7️⃣'): print('Jackpot! 💰') else: - print('Thanks for playing!') \ No newline at end of file + print('Thanks for playing!') From 1a654ca85ed71e117afd1b87d23661fdcdff79db Mon Sep 17 00:00:00 2001 From: vance Date: Thu, 30 Mar 2023 02:52:13 -0400 Subject: [PATCH 14/73] Fix typo in 28_dry.py Remove extra "the" --- 6-functions/28_dry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-functions/28_dry.py b/6-functions/28_dry.py index 162175a..79a4dcf 100644 --- a/6-functions/28_dry.py +++ b/6-functions/28_dry.py @@ -17,5 +17,5 @@ # This function calculates the length of a list print(len(list_of_foods)) -# This function calculates the a to the power b +# This function calculates a to the power b print(pow(2, 6)) From 5c59494325251b0e28dfbdd32158507f09e7fd9c Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 13 Apr 2023 12:33:08 -0400 Subject: [PATCH 15/73] Update 34_restaurants.py --- 7-classes-objects/34_restaurants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/7-classes-objects/34_restaurants.py b/7-classes-objects/34_restaurants.py index 9ee4a98..b8e1299 100644 --- a/7-classes-objects/34_restaurants.py +++ b/7-classes-objects/34_restaurants.py @@ -3,6 +3,6 @@ class Restaurant: name = '' - type = '' + description = '' rating = 0.0 - deliver = True \ No newline at end of file + deliver = True From 172ed7b40952e969b5b5d14e65d4b3b1c91f4774 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 17 Apr 2023 08:14:50 -0400 Subject: [PATCH 16/73] Update 38_pokedex.py --- 7-classes-objects/38_pokedex.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/7-classes-objects/38_pokedex.py b/7-classes-objects/38_pokedex.py index 092f7e1..efe04f2 100644 --- a/7-classes-objects/38_pokedex.py +++ b/7-classes-objects/38_pokedex.py @@ -24,7 +24,7 @@ def display_details(self): else: print('Type: ' + self.type[0] + '/' + self.type[1]) - print('Lv. ' + self.level) + print('Lv. ' + str(self.level)) print('Region: ' + self.region) print('Description: ' + self.description) @@ -39,6 +39,3 @@ def display_details(self): charizard = Pokemon("Charizard", ["Fire", "Flying"], " It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.", 36, "Kanto", False) gyarados = Pokemon("Gyarados", ["Water", "Flying"], "It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.", 57, "Kanto", False) - - - From 28accada26925ee2aefbe02e6bd6d4fa885553c0 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Wed, 19 Apr 2023 08:26:06 -0400 Subject: [PATCH 17/73] Rename bday_messages.py to 41_bday_messages.py --- 8-modules/{bday_messages.py => 41_bday_messages.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename 8-modules/{bday_messages.py => 41_bday_messages.py} (88%) diff --git a/8-modules/bday_messages.py b/8-modules/41_bday_messages.py similarity index 88% rename from 8-modules/bday_messages.py rename to 8-modules/41_bday_messages.py index 02659fb..b0667fd 100644 --- a/8-modules/bday_messages.py +++ b/8-modules/41_bday_messages.py @@ -11,4 +11,4 @@ 'Another year of you going around the sun! 🌞' ] -random_message = random.choice(bday_messages) \ No newline at end of file +random_message = random.choice(bday_messages) From e87d21c5e767efdc364ed3ead3dbcfda473bc31e Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 8 May 2023 00:09:45 -0400 Subject: [PATCH 18/73] Update 41_main.py --- 8-modules/41_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8-modules/41_main.py b/8-modules/41_main.py index fdae76e..389d894 100644 --- a/8-modules/41_main.py +++ b/8-modules/41_main.py @@ -13,4 +13,4 @@ if my_next_birthday == today: print(bday_messages.random_message) else: - print(f'My next birthday is {days_away} away!') \ No newline at end of file + print(f'My next birthday is {days_away.days} days away!') From ff7317837835a11ff7347505824f6e6aaf140e3a Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 8 May 2023 14:02:15 -0400 Subject: [PATCH 19/73] Update 40_solar_system.py --- 8-modules/40_solar_system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8-modules/40_solar_system.py b/8-modules/40_solar_system.py index 68b5995..7388ce0 100644 --- a/8-modules/40_solar_system.py +++ b/8-modules/40_solar_system.py @@ -29,4 +29,4 @@ planet_area = 4 * pi * radius * radius -print(f'Area of {random_planet}: {planet_area} km2') \ No newline at end of file +print(f'Area of {random_planet}: {planet_area} sq mi') From 4ca53ef249b23e3270a2db068b48a602ba008361 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 22 May 2023 00:06:18 -0400 Subject: [PATCH 20/73] Delete 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 3-control-flow/15_the_cyclone_2.py diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py deleted file mode 100644 index 823d034..0000000 --- a/3-control-flow/15_the_cyclone_2.py +++ /dev/null @@ -1,18 +0,0 @@ -# The Cyclone 🎢 -# Codédex - -height = 250 -credits = 10 -with_taller_person = False - -if credits < 10: - print("You don't have enough credits to ride.") -elif height >= 137 and credits >= 10: - print("Enjoy the ride!") -elif height < 137: - if height < 100 or not with_taller_person: - print("You're not tall enough for this ride yet.") - elif height >= 100 and with_taller_person: - print("Enjoy the ride, folks!") -else: - print("Invalid data.") From a8dfdc5cb412d8fa0b8fb147868d21c292a3ef83 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sun, 11 Jun 2023 17:07:19 -0400 Subject: [PATCH 21/73] Update 15_the_cyclone_1.py --- 3-control-flow/15_the_cyclone_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3-control-flow/15_the_cyclone_1.py b/3-control-flow/15_the_cyclone_1.py index 6fc44b5..34c74c0 100644 --- a/3-control-flow/15_the_cyclone_1.py +++ b/3-control-flow/15_the_cyclone_1.py @@ -1,8 +1,8 @@ # The Cyclone 🎢 # Codédex -height = 250 -credits = 10 +height = int(input('What is your height (cm)?')) +credits = int(input('How many credits do you have?')) if height >= 137 and credits >= 10: print("Enjoy the ride!") From a32d660667c5197bc9bcb0525517c5ee5b04aedd Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sun, 11 Jun 2023 17:09:14 -0400 Subject: [PATCH 22/73] Update 15_the_cyclone_1.py --- 3-control-flow/15_the_cyclone_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3-control-flow/15_the_cyclone_1.py b/3-control-flow/15_the_cyclone_1.py index 34c74c0..44fa81d 100644 --- a/3-control-flow/15_the_cyclone_1.py +++ b/3-control-flow/15_the_cyclone_1.py @@ -1,8 +1,8 @@ # The Cyclone 🎢 # Codédex -height = int(input('What is your height (cm)?')) -credits = int(input('How many credits do you have?')) +height = int(input('What is your height (cm)? ')) +credits = int(input('How many credits do you have? ')) if height >= 137 and credits >= 10: print("Enjoy the ride!") From 86848ce29b2c290ea24a122517ff165bf3b3140c Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Tue, 13 Jun 2023 14:30:54 -0400 Subject: [PATCH 23/73] Update 09_hypotenuse.py --- 2-variables/09_hypotenuse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-variables/09_hypotenuse.py b/2-variables/09_hypotenuse.py index 7e7b52c..9b1894f 100644 --- a/2-variables/09_hypotenuse.py +++ b/2-variables/09_hypotenuse.py @@ -4,6 +4,6 @@ a = int(input("Enter a: ")) b = int(input("Enter b: ")) -c = (a*a + b*b)**0.5 +c = (a**2 + b**2) ** 0.5 print(c) From b82a43ec2903b25a8894d50d59894d4418bb5ab1 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 21 Jun 2023 01:12:48 -0400 Subject: [PATCH 24/73] Update 10_currency.py --- 2-variables/10_currency.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2-variables/10_currency.py b/2-variables/10_currency.py index e66434c..8c9f78b 100644 --- a/2-variables/10_currency.py +++ b/2-variables/10_currency.py @@ -1,10 +1,10 @@ # Currency 💵 # Codédex -yuan = int(input('What do you have left in yuan? ')) -yen = int(input('What do you have left in yen? ')) -won = int(input('What do you have left in won? ')) +pesos = int(input('What do you have left in pesos? ')) +soles = int(input('What do you have left in soles? ')) +reais = int(input('What do you have left in reais? ')) -total = yuan * 0.15 + yen * 0.0077 + won * 0.00080 +total = pesos * 0.058 + soles * 0.28 + reais * 0.21 print(total) From 27ed01f6c73f472c4ca1588c83657d6910648529 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 20:47:44 -0400 Subject: [PATCH 25/73] Add badge files for Python Ch. 7 & Ch. 8 --- assets/classes-and-objects.png | Bin 0 -> 349 bytes assets/modules.png | Bin 0 -> 293 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/classes-and-objects.png create mode 100644 assets/modules.png diff --git a/assets/classes-and-objects.png b/assets/classes-and-objects.png new file mode 100644 index 0000000000000000000000000000000000000000..2662aa74c8c61ce40c59a318009ecb4c49e4ec66 GIT binary patch literal 349 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T<;+`&!ArY;~ z2@Ti&LsfA7w*OnzZgodqljrIKf!_ixu**rmGZo*@qp&kg6Kf>s8- z`TyfK3$9MPCQ#1?1Z~q@uSPsQ`a3G{#|@{X1I`Vs^Ht6~H<4jY@W5kIElhP9; z-Y7Qk6)bHnKkm2i!^fWzvOH@A9N1sjsk8IE6F4ySSK-f^>$m%XHt_Il46rlIOe|<) z(D{F;c1r;lGc$AI{Kd^jKU#vN^A7#7kTtMyZir|&{d`HoLP4etLISp-$CHB3H0(Zd zgpIA7!{x^=BLg5gTe~DWM4fKh1?- literal 0 HcmV?d00001 diff --git a/assets/modules.png b/assets/modules.png new file mode 100644 index 0000000000000000000000000000000000000000..655590a6949b097f4ff112f20d2c4501e36492a2 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}_dQ)4Ln2y} zQyiGHZt4BMcytA0UhLh&9lmoq#imVUiYV~BvuD$6rRJ-pF@a|SuNVG3f1p89sM(w) z;lYEMyG0@yF3*n&H~<0$)lAG@9z6d97KkiSO?fa?-byhb^k!@5p0#^ff1#wifCj*;b{EmYV0}ipUv9&Fn!F}N}!@3>Em-2~Ad=QZE zWmZ|v7*oj0yyFs^p1}h}gIR2DvJQp09eiyudJ0x796wuPzB0=(E#_00!Iq#ZvG%|N jUdD*~eb*8WI5RNxDy6S#SegN3F)(<#`njxgN@xNAAmwi; literal 0 HcmV?d00001 From 3492eebad940a80fc06fad45bad20941dbf68f02 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 20:51:40 -0400 Subject: [PATCH 26/73] Add files via upload --- assets/badge_classes_and_objects.png | Bin 0 -> 349 bytes assets/badge_modules.png | Bin 0 -> 293 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/badge_classes_and_objects.png create mode 100644 assets/badge_modules.png diff --git a/assets/badge_classes_and_objects.png b/assets/badge_classes_and_objects.png new file mode 100644 index 0000000000000000000000000000000000000000..2662aa74c8c61ce40c59a318009ecb4c49e4ec66 GIT binary patch literal 349 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T<;+`&!ArY;~ z2@Ti&LsfA7w*OnzZgodqljrIKf!_ixu**rmGZo*@qp&kg6Kf>s8- z`TyfK3$9MPCQ#1?1Z~q@uSPsQ`a3G{#|@{X1I`Vs^Ht6~H<4jY@W5kIElhP9; z-Y7Qk6)bHnKkm2i!^fWzvOH@A9N1sjsk8IE6F4ySSK-f^>$m%XHt_Il46rlIOe|<) z(D{F;c1r;lGc$AI{Kd^jKU#vN^A7#7kTtMyZir|&{d`HoLP4etLISp-$CHB3H0(Zd zgpIA7!{x^=BLg5gTe~DWM4fKh1?- literal 0 HcmV?d00001 diff --git a/assets/badge_modules.png b/assets/badge_modules.png new file mode 100644 index 0000000000000000000000000000000000000000..655590a6949b097f4ff112f20d2c4501e36492a2 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}_dQ)4Ln2y} zQyiGHZt4BMcytA0UhLh&9lmoq#imVUiYV~BvuD$6rRJ-pF@a|SuNVG3f1p89sM(w) z;lYEMyG0@yF3*n&H~<0$)lAG@9z6d97KkiSO?fa?-byhb^k!@5p0#^ff1#wifCj*;b{EmYV0}ipUv9&Fn!F}N}!@3>Em-2~Ad=QZE zWmZ|v7*oj0yyFs^p1}h}gIR2DvJQp09eiyudJ0x796wuPzB0=(E#_00!Iq#ZvG%|N jUdD*~eb*8WI5RNxDy6S#SegN3F)(<#`njxgN@xNAAmwi; literal 0 HcmV?d00001 From 277f887ad153f2f750892dd77008d17672445893 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 20:52:06 -0400 Subject: [PATCH 27/73] Delete modules.png --- assets/modules.png | Bin 293 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 assets/modules.png diff --git a/assets/modules.png b/assets/modules.png deleted file mode 100644 index 655590a6949b097f4ff112f20d2c4501e36492a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}_dQ)4Ln2y} zQyiGHZt4BMcytA0UhLh&9lmoq#imVUiYV~BvuD$6rRJ-pF@a|SuNVG3f1p89sM(w) z;lYEMyG0@yF3*n&H~<0$)lAG@9z6d97KkiSO?fa?-byhb^k!@5p0#^ff1#wifCj*;b{EmYV0}ipUv9&Fn!F}N}!@3>Em-2~Ad=QZE zWmZ|v7*oj0yyFs^p1}h}gIR2DvJQp09eiyudJ0x796wuPzB0=(E#_00!Iq#ZvG%|N jUdD*~eb*8WI5RNxDy6S#SegN3F)(<#`njxgN@xNAAmwi; From 0fede117121995ba3a5f9ae31d1440070eb69518 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 20:52:25 -0400 Subject: [PATCH 28/73] Delete classes-and-objects.png --- assets/classes-and-objects.png | Bin 349 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 assets/classes-and-objects.png diff --git a/assets/classes-and-objects.png b/assets/classes-and-objects.png deleted file mode 100644 index 2662aa74c8c61ce40c59a318009ecb4c49e4ec66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 349 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T<;+`&!ArY;~ z2@Ti&LsfA7w*OnzZgodqljrIKf!_ixu**rmGZo*@qp&kg6Kf>s8- z`TyfK3$9MPCQ#1?1Z~q@uSPsQ`a3G{#|@{X1I`Vs^Ht6~H<4jY@W5kIElhP9; z-Y7Qk6)bHnKkm2i!^fWzvOH@A9N1sjsk8IE6F4ySSK-f^>$m%XHt_Il46rlIOe|<) z(D{F;c1r;lGc$AI{Kd^jKU#vN^A7#7kTtMyZir|&{d`HoLP4etLISp-$CHB3H0(Zd zgpIA7!{x^=BLg5gTe~DWM4fKh1?- From fe060d9b89269a8b29574ebeef2789f0543df357 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 20:59:37 -0400 Subject: [PATCH 29/73] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 7d33798..3e7b257 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,24 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`stonks.py`](https://github.com/codedex-io/python-101/blob/main/6-functions/32_stonks.py) - [`drive_thru.py`](https://github.com/codedex-io/python-101/blob/main/6-functions/33_drive_thru.py) +## Classes & Objects + +- [`restaurants.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/34_restaurants.py) +- [`bobs_burgers.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/35_bobs_burgers.py) +- [`favorite_cities.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/36_favorite_cities.py) +- [`bank_accounts.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/37_bank_accounts.py) +- [`pokedex.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/38_pokedex.py) + +## Modules + +- [`slot_machine.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/39_slot_machine_1.py) (solution 1) +- [`slot_machine.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/39_slot_machine_2.py) (solution 2) +- [`solar_system.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/40_solar_system.py) +- [`bday_messages.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/41_bday_messages.py) (for exercise 41) +- [`main.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/41_main.py) (for exercise 41) +- [`forty_two.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/42_forty_two.py) +- [`zen.py`](https://github.com/codedex-io/python-101/blob/main/8-modules/43_zen.py) + --- Make sure to join the [Codédex Club or Workshops](https://www.codedex.io/community) for more problems! 💖 From 1a2a82e4b6b2baf83abd20a7271d5586f2f82f3a Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 29 Jun 2023 22:05:06 -0400 Subject: [PATCH 30/73] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e7b257..09b0178 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`quadratic.py`](https://github.com/codedex-io/python-101/blob/main/2-variables/09_quadratic.py) - [`currency.py`](https://github.com/codedex-io/python-101/blob/main/2-variables/10_currency.py) -## Control Flow +## Control Flow - [`coin_flip.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/11_coin_flip.py) - [`grades.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/12_grades.py) @@ -41,7 +41,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles.py) - [`fizz_buzz.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/21_fizz_buzz.py) -## Lists +## Lists - [`grocery.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/22_grocery.py) - [`todo.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/23_todo.py) @@ -60,7 +60,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`stonks.py`](https://github.com/codedex-io/python-101/blob/main/6-functions/32_stonks.py) - [`drive_thru.py`](https://github.com/codedex-io/python-101/blob/main/6-functions/33_drive_thru.py) -## Classes & Objects +## Classes & Objects - [`restaurants.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/34_restaurants.py) - [`bobs_burgers.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/35_bobs_burgers.py) From 9202e662e775eee0ce60da192b777d0f9cbd320e Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 3 Jul 2023 08:53:53 -0400 Subject: [PATCH 31/73] Update 32_stonks.py --- 6-functions/32_stonks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/6-functions/32_stonks.py b/6-functions/32_stonks.py index b300b9b..7290ebc 100644 --- a/6-functions/32_stonks.py +++ b/6-functions/32_stonks.py @@ -8,13 +8,13 @@ def price_at(i): def max_price(a, b): mx = 0 - for i in range(a, b): + for i in range(a, b + 1): mx = max(mx, price_at(i)) return mx def min_price(a, b): mn = price_at(a) - for i in range(a, b): + for i in range(a, b + 1): mn = min(mn, price_at(i)) return mn From 03a4d33fff189a696e36006db066298d6beb31bd Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Tue, 11 Jul 2023 14:27:54 -0400 Subject: [PATCH 32/73] Update 15_the_cyclone_1.py --- 3-control-flow/15_the_cyclone_1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3-control-flow/15_the_cyclone_1.py b/3-control-flow/15_the_cyclone_1.py index 44fa81d..fadabd1 100644 --- a/3-control-flow/15_the_cyclone_1.py +++ b/3-control-flow/15_the_cyclone_1.py @@ -6,9 +6,9 @@ if height >= 137 and credits >= 10: print("Enjoy the ride!") -elif height < 137: +elif height < 137 and credits >= 10: print("You are not tall enough to ride.") -elif credits < 10: +elif credits < 10 and height >= 137: print("You don't have enough credits to ride.") else: - print("Invalid data.") + print("You are not tall enough for this ride, nor do you have enough credits.") From a5d8db4af31dbf94c4cbabf0dc1dc7a88b5b0a74 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Tue, 11 Jul 2023 14:49:40 -0400 Subject: [PATCH 33/73] Create 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 3-control-flow/15_the_cyclone_2.py diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py new file mode 100644 index 0000000..5b2be3d --- /dev/null +++ b/3-control-flow/15_the_cyclone_2.py @@ -0,0 +1,17 @@ +# The Cyclone 🎢 +# Codédex + +is_open = False + +height = int(input('What is your height (cm)? ')) +credits = int(input('How many credits do you have? ')) + +not_tall_enough = height < 137 and credits >= 10 +not_enough_credits = credits < 10 and height >= 137 + +if not is_open: + print("Sorry! The ride is currently closed!") +elif not_tall_enough or not_enough_credits: + print("You are either not tall enough to ride or you don't have enough credits.") +else: + print("Enjoy the ride!") From d117c234319578e52796e1ec9b3e26dcbf3a6051 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Tue, 11 Jul 2023 14:51:16 -0400 Subject: [PATCH 34/73] Update 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 5b2be3d..4999c2e 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -1,7 +1,7 @@ # The Cyclone 🎢 # Codédex -is_open = False +is_open = True height = int(input('What is your height (cm)? ')) credits = int(input('How many credits do you have? ')) From a7c4f914da898f7d072cd251f0d55386c68e68eb Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Tue, 25 Jul 2023 17:05:07 -0400 Subject: [PATCH 35/73] Update .gitignore --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 22212bc..e4f969f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,3 @@ *.air *.ipa *.apk - -# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` -# should NOT be excluded as they contain compiler settings and other important -# information for Eclipse / Flash Builder. From c43df892aa20ac78429ccde9b509e92581808c28 Mon Sep 17 00:00:00 2001 From: b321gonzo Date: Tue, 25 Jul 2023 16:33:47 -0500 Subject: [PATCH 36/73] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09b0178..6c3fc75 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@
-Welcome to The Legend of Python GitHub repo! We are super excited to have you. Here, you will find all the solutions to the Codédex challenges. Feel free to make pull requests to add your own twists on the challenges! +Welcome to The Legend of Python GitHub repo! We are super excited to have you. Here, you will find all the solutions to the Codédex exercises. Feel free to make pull requests to add your own twists on the exercises! ### Website: www.codedex.io From ba922d0e21ddac5dcc841a2e940d3390a6e53502 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Wed, 26 Jul 2023 09:16:54 -0400 Subject: [PATCH 37/73] Update 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 4999c2e..2f270cd 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -6,12 +6,12 @@ height = int(input('What is your height (cm)? ')) credits = int(input('How many credits do you have? ')) -not_tall_enough = height < 137 and credits >= 10 -not_enough_credits = credits < 10 and height >= 137 +tall_enough = height >= 137 +not_enough_credits = credits < 10 if not is_open: print("Sorry! The ride is currently closed!") -elif not_tall_enough or not_enough_credits: +elif not tall_enough or not_enough_credits: print("You are either not tall enough to ride or you don't have enough credits.") else: print("Enjoy the ride!") From d55e52e8bea0f6da054c87e23c3e2c517efb1a30 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Wed, 26 Jul 2023 09:31:09 -0400 Subject: [PATCH 38/73] Update 15_the_cyclone_2.py --- 3-control-flow/15_the_cyclone_2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/3-control-flow/15_the_cyclone_2.py b/3-control-flow/15_the_cyclone_2.py index 2f270cd..7a79377 100644 --- a/3-control-flow/15_the_cyclone_2.py +++ b/3-control-flow/15_the_cyclone_2.py @@ -1,17 +1,17 @@ # The Cyclone 🎢 # Codédex -is_open = True +ride_is_open = True height = int(input('What is your height (cm)? ')) credits = int(input('How many credits do you have? ')) tall_enough = height >= 137 -not_enough_credits = credits < 10 +enough_credits = credits >= 10 -if not is_open: - print("Sorry! The ride is currently closed!") -elif not tall_enough or not_enough_credits: +if ride_is_open and tall_enough and enough_credits: + print("Enjoy the ride!") +elif not tall_enough or not enough_credits: print("You are either not tall enough to ride or you don't have enough credits.") else: - print("Enjoy the ride!") + print("Sorry! The ride is currently closed!") From fe8388a9c5315fafbc48569ab518760d3e0925d3 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Thu, 3 Aug 2023 09:46:07 -0400 Subject: [PATCH 39/73] Update 10_currency.py --- 2-variables/10_currency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-variables/10_currency.py b/2-variables/10_currency.py index 8c9f78b..bb949a1 100644 --- a/2-variables/10_currency.py +++ b/2-variables/10_currency.py @@ -5,6 +5,6 @@ soles = int(input('What do you have left in soles? ')) reais = int(input('What do you have left in reais? ')) -total = pesos * 0.058 + soles * 0.28 + reais * 0.21 +total = pesos * 0.00025 + soles * 0.28 + reais * 0.21 print(total) From 9e5d0182d333002f9dfe62835242dfbece2ef2f0 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Wed, 9 Aug 2023 10:23:04 -0400 Subject: [PATCH 40/73] combine both files for exercise 41 into one file --- 8-modules/41_bday_messages.py | 13 ++++++++++++- 8-modules/41_main.py | 16 ---------------- 2 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 8-modules/41_main.py diff --git a/8-modules/41_bday_messages.py b/8-modules/41_bday_messages.py index b0667fd..29a3525 100644 --- a/8-modules/41_bday_messages.py +++ b/8-modules/41_bday_messages.py @@ -1,7 +1,7 @@ # Countdown 🎂 # Codédex -import random +import random, datetime bday_messages = [ 'Hope you have a very Happy Birthday! 🎈', @@ -12,3 +12,14 @@ ] random_message = random.choice(bday_messages) + +today = datetime.date.today() + +my_next_birthday = datetime.date(2023, 4, 5) + +days_away = my_next_birthday - today + +if my_next_birthday == today: + print(bday_messages.random_message) +else: + print(f'My next birthday is {days_away.days} days away!') diff --git a/8-modules/41_main.py b/8-modules/41_main.py deleted file mode 100644 index 389d894..0000000 --- a/8-modules/41_main.py +++ /dev/null @@ -1,16 +0,0 @@ -# Birthday Card 🎂 -# Codédex - -import datetime -import bday_messages - -today = datetime.date.today() - -my_next_birthday = datetime.date(2023, 4, 5) - -days_away = my_next_birthday - today - -if my_next_birthday == today: - print(bday_messages.random_message) -else: - print(f'My next birthday is {days_away.days} days away!') From 00968bf27d206a917ec2625637f467681cd7ef9b Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Wed, 9 Aug 2023 10:27:53 -0400 Subject: [PATCH 41/73] rename solution file for exercise #41 --- 8-modules/{41_bday_messages.py => 41_countdown.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 8-modules/{41_bday_messages.py => 41_countdown.py} (100%) diff --git a/8-modules/41_bday_messages.py b/8-modules/41_countdown.py similarity index 100% rename from 8-modules/41_bday_messages.py rename to 8-modules/41_countdown.py From 78cc46136e96fb1e525af34a579a6c111cfcf674 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Wed, 9 Aug 2023 12:24:14 -0400 Subject: [PATCH 42/73] bring back main.py and bday_message.py files --- .../{41_countdown.py => 41_bday_messages.py} | 15 ++------------- 8-modules/41_main.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) rename 8-modules/{41_countdown.py => 41_bday_messages.py} (52%) create mode 100644 8-modules/41_main.py diff --git a/8-modules/41_countdown.py b/8-modules/41_bday_messages.py similarity index 52% rename from 8-modules/41_countdown.py rename to 8-modules/41_bday_messages.py index 29a3525..02659fb 100644 --- a/8-modules/41_countdown.py +++ b/8-modules/41_bday_messages.py @@ -1,7 +1,7 @@ # Countdown 🎂 # Codédex -import random, datetime +import random bday_messages = [ 'Hope you have a very Happy Birthday! 🎈', @@ -11,15 +11,4 @@ 'Another year of you going around the sun! 🌞' ] -random_message = random.choice(bday_messages) - -today = datetime.date.today() - -my_next_birthday = datetime.date(2023, 4, 5) - -days_away = my_next_birthday - today - -if my_next_birthday == today: - print(bday_messages.random_message) -else: - print(f'My next birthday is {days_away.days} days away!') +random_message = random.choice(bday_messages) \ No newline at end of file diff --git a/8-modules/41_main.py b/8-modules/41_main.py new file mode 100644 index 0000000..42cd469 --- /dev/null +++ b/8-modules/41_main.py @@ -0,0 +1,15 @@ +# Countdown 🎂 +# Codédex + +import datetime, bday_messages + +today = datetime.date.today() + +my_next_birthday = datetime.date(2023, 4, 5) + +days_away = my_next_birthday - today + +if my_next_birthday == today: + print(bday_messages.random_message) +else: + print(f'My next birthday is {days_away.days} days away!') From 79acb943c716ffffe9e1e3123b785dbcf88a4719 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Mon, 20 Nov 2023 09:48:57 -0500 Subject: [PATCH 43/73] add second solution for Pokemon exercise --- 7-classes-objects/38_pokedex.py | 41 ----------------------------- 7-classes-objects/38_pokedex_1.py | 39 ++++++++++++++++++++++++++++ 7-classes-objects/38_pokedex_2.py | 43 +++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 41 deletions(-) delete mode 100644 7-classes-objects/38_pokedex.py create mode 100644 7-classes-objects/38_pokedex_1.py create mode 100644 7-classes-objects/38_pokedex_2.py diff --git a/7-classes-objects/38_pokedex.py b/7-classes-objects/38_pokedex.py deleted file mode 100644 index efe04f2..0000000 --- a/7-classes-objects/38_pokedex.py +++ /dev/null @@ -1,41 +0,0 @@ -# Pokédex 📟 -# Codédex - -# Class definition -class Pokemon: - def __init__(self, name, type, description, level, region, is_caught): - self.name = name - self.type = type - self.description = description - self.level = level - self.region = region - self.is_caught = is_caught - - # Instance method - def speak(self): - print(self.name + ' made a sound!') - - # Instance method - def display_details(self): - print('Name: ' + self.name) - - if len(self.type) == 1: - print('Type: ' + self.type[0]) - else: - print('Type: ' + self.type[0] + '/' + self.type[1]) - - print('Lv. ' + str(self.level)) - print('Region: ' + self.region) - print('Description: ' + self.description) - - if self.is_caught: - print(self.name + ' has already been caught!') - else: - print(self.name + ' hasn\'t been caught yet.') - -# Pokémon objects -pikachu = Pokemon("Pikachu", ["Electric"], " It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.", 25, "Kanto", True) - -charizard = Pokemon("Charizard", ["Fire", "Flying"], " It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.", 36, "Kanto", False) - -gyarados = Pokemon("Gyarados", ["Water", "Flying"], "It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.", 57, "Kanto", False) diff --git a/7-classes-objects/38_pokedex_1.py b/7-classes-objects/38_pokedex_1.py new file mode 100644 index 0000000..6b533ee --- /dev/null +++ b/7-classes-objects/38_pokedex_1.py @@ -0,0 +1,39 @@ +# Pokédex 📟 +# Codédex + +# Class definition +class Pokemon: + def __init__(self, entry, name, types, description, is_caught): + self.entry = entry + self.name = name + self.types = types + self.description = description + self.is_caught = is_caught + + def speak(self): + print(self.name + ', ' + self.name + '!') + + def display_details(self): + print('Entry Number: ' + str(self.entry)) + print('Name: ' + self.name) + + if len(self.types) == 1: + print('Type: ' + self.types[0]) + else: + print('Type: ' + self.types[0] + '/' + self.types[1]) + + print('Description: ' + self.description) + + if self.is_caught: + print(self.name + ' has already been caught!') + else: + print(self.name + ' hasn\'t been caught yet.') + +# Pokémon objects +pikachu = Pokemon(25, 'Pikachu', ['Electric'], 'It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.', True) +charizard = Pokemon(3, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', False) +gyarados = Pokemon(130, 'Gyarados', ['Water', 'Flying'], 'It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.', False) + +pikachu.speak() +charizard.speak() +gyarados.speak() \ No newline at end of file diff --git a/7-classes-objects/38_pokedex_2.py b/7-classes-objects/38_pokedex_2.py new file mode 100644 index 0000000..b483644 --- /dev/null +++ b/7-classes-objects/38_pokedex_2.py @@ -0,0 +1,43 @@ +# Pokédex 📟 +# Codédex + +# Class definition +class Pokemon: + def __init__(self, entry, name, types, description, level, region, is_caught): + self.entry = entry + self.name = name + self.types = types + self.description = description + self.level = level + self.region = region + self.is_caught = is_caught + + def speak(self): + print(self.name + ', ' + self.name + '!') + + def display_details(self): + print('Entry Number: ' + str(self.entry)) + print('Name: ' + self.name) + + if len(self.types) == 1: + print('Type: ' + self.types[0]) + else: + print('Type: ' + self.types[0] + '/' + self.types[1]) + + print('Lv. ' + str(self.level)) + print('Region: ' + self.region) + print('Description: ' + self.description) + + if self.is_caught: + print(self.name + ' has already been caught!') + else: + print(self.name + ' hasn\'t been caught yet.') + +# Pokémon objects +pikachu = Pokemon(25, 'Pikachu', ['Electric'], 'It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.', 25, 'Kanto', True) +charizard = Pokemon(3, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', 36, 'Kanto', False) +gyarados = Pokemon(130, 'Gyarados', ['Water', 'Flying'], 'It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.', 57, 'Kanto', False) + +pikachu.speak() +charizard.speak() +gyarados.speak() \ No newline at end of file From 500215cfc547b913c6b58bcbfdd640b7acac4aa5 Mon Sep 17 00:00:00 2001 From: Dusch4593 Date: Sat, 6 Jan 2024 18:22:27 -0500 Subject: [PATCH 44/73] update Magic 8 Ball solution --- 3-control-flow/14_magic_8_ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3-control-flow/14_magic_8_ball.py b/3-control-flow/14_magic_8_ball.py index 539b5f4..291704e 100644 --- a/3-control-flow/14_magic_8_ball.py +++ b/3-control-flow/14_magic_8_ball.py @@ -3,7 +3,7 @@ import random -question = input() +question = input('Question: ') random_number = random.randint(1, 9) From 444e49ab4d44aaabe041e1e87f3eacbe2bc2f639 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 24 Jan 2024 09:07:42 -0500 Subject: [PATCH 45/73] Update 20_99_bottles.py --- 4-loops/20_99_bottles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/4-loops/20_99_bottles.py b/4-loops/20_99_bottles.py index 428f671..38d7eb3 100644 --- a/4-loops/20_99_bottles.py +++ b/4-loops/20_99_bottles.py @@ -4,5 +4,5 @@ for i in range(99, 0, -1): print(f'{i} bottles of beer on the wall') print(f'{i} bottles of beer') - print('take one down pass it around') + print('Take one down, pass it around') print(f'{i-1} bottles of beer on the wall') From 6190b67907273b2d9b4a6aeaa9b886708478edd5 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 24 Jan 2024 09:18:18 -0500 Subject: [PATCH 46/73] Update 14_magic_8_ball.py --- 3-control-flow/14_magic_8_ball.py | 1 - 1 file changed, 1 deletion(-) diff --git a/3-control-flow/14_magic_8_ball.py b/3-control-flow/14_magic_8_ball.py index 291704e..8a620d2 100644 --- a/3-control-flow/14_magic_8_ball.py +++ b/3-control-flow/14_magic_8_ball.py @@ -28,5 +28,4 @@ else: answer = 'Error' -print('Question: ' + question) print('Magic 8 Ball: ' + answer) From 80139a370660a2113fc71e3a6753d864febb20f4 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sat, 13 Apr 2024 20:42:10 -0400 Subject: [PATCH 47/73] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c3fc75..9399c6a 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,4 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H --- -Make sure to join the [Codédex Club or Workshops](https://www.codedex.io/community) for more problems! 💖 +Make sure to join the [community](https://www.codedex.io/community) and [Codédex Club](https://www.codedex.io/pricing) for more content! 💖 From 6abd8ae7b5a42fc1bacff3262b27b87088ad7c9a Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sat, 13 Apr 2024 23:14:54 -0400 Subject: [PATCH 48/73] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9399c6a..fad5185 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. Here, you will find all the solutions to the Codédex exercises. Feel free to make pull requests to add your own twists on the exercises! -### Website: www.codedex.io +### Website: www.codedex.io/python ## Hello World From 5ec5b285737bd26666d75098b6202c07a5f3374b Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 2 Oct 2024 00:17:08 -0400 Subject: [PATCH 49/73] Update 27_bucket_list.py --- 5-lists/27_bucket_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-lists/27_bucket_list.py b/5-lists/27_bucket_list.py index ea7fae1..0c4e2f8 100644 --- a/5-lists/27_bucket_list.py +++ b/5-lists/27_bucket_list.py @@ -1,4 +1,4 @@ -# Bucket List: Jerry Zhu +# Bucket List 🪣 # Codédex things_to_do = [ From a6fc99aa09e70b5f770e8965f2bee108fc7023b1 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Thu, 3 Oct 2024 00:35:57 -0400 Subject: [PATCH 50/73] Update 32_stonks.py --- 6-functions/32_stonks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-functions/32_stonks.py b/6-functions/32_stonks.py index 7290ebc..d2ba9d6 100644 --- a/6-functions/32_stonks.py +++ b/6-functions/32_stonks.py @@ -1,7 +1,7 @@ # Stonks 📈 # Codédex -stock_prices = [ 6.15, 5.81, 5.70, 5.65, 5.33, 5.62, 5.19, 6.13, 7.20, 7.34, 7.95, 7.53, 7.39, 7.59, 7.27 ] +stock_prices = [34.68, 36.09, 34.94, 33.97, 34.68, 35.82, 43.41, 44.29, 44.65, 53.56, 49.85, 48.71, 48.71, 49.94, 48.53, 47.03, 46.59, 48.62, 44.21, 47.21] def price_at(i): return stock_prices[i-1] From f304d4b1c5f1d108f19ebd5ad3d073a59298734c Mon Sep 17 00:00:00 2001 From: Jakub Sova Date: Thu, 10 Oct 2024 18:03:34 +0200 Subject: [PATCH 51/73] fix: link (Ch. 3 Exercise 15) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fad5185..39249a4 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`grades.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/12_grades.py) - [`ph_levels.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/13_ph_levels.py) - [`magic_8_ball.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/14_magic_8_ball.py) -- [`the_cyclone.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/15_the_cyclone.py) +- [`the_cyclone.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/15_the_cyclone_1.py) (solution 1) +- [`the_cyclone.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/15_the_cyclone_2.py) (solution 2) - [`sorting_hat.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/16_sorting_hat_1.py) (solution 1) - [`sorting_hat.py`](https://github.com/codedex-io/python-101/blob/main/3-control-flow/16_sorting_hat_2.py) (solution 2) From 3bce0cc963c919ca93c241d25802dc994f363b54 Mon Sep 17 00:00:00 2001 From: Jakub Sova Date: Thu, 10 Oct 2024 18:08:45 +0200 Subject: [PATCH 52/73] fix: link (Ch. 5 Exercise 25) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fad5185..1ba0037 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`grocery.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/22_grocery.py) - [`todo.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/23_todo.py) - [`inventory.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/24_inventory.py) -- [`reading.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/25_reading.py) +- [`reading.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/25_reading_list.py) - [`mixtape.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/26_mixtape.py) - [`bucket_list.py`](https://github.com/codedex-io/python-101/blob/main/5-lists/27_bucket_list.py) From 94eb3dd3f820ec2f2022ccbb56426980350ce33c Mon Sep 17 00:00:00 2001 From: Jakub Sova Date: Thu, 10 Oct 2024 18:13:57 +0200 Subject: [PATCH 53/73] fix: link (Ch. 7 Exercise 38) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fad5185..49ab6d8 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,8 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`bobs_burgers.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/35_bobs_burgers.py) - [`favorite_cities.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/36_favorite_cities.py) - [`bank_accounts.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/37_bank_accounts.py) -- [`pokedex.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/38_pokedex.py) +- [`pokedex.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/38_pokedex_1.py) (solution 1) +- [`pokedex.py`](https://github.com/codedex-io/python-101/blob/main/7-classes-objects/38_pokedex_2.py) (solution 2) ## Modules From f1b0e18027299d7b2c20b0172308fe038263d4be Mon Sep 17 00:00:00 2001 From: Milan Date: Fri, 11 Oct 2024 13:27:58 +0200 Subject: [PATCH 54/73] Fixed typo in lesson 09. --- 2-variables/09_hypotenuse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-variables/09_hypotenuse.py b/2-variables/09_hypotenuse.py index 9b1894f..eb6b9e7 100644 --- a/2-variables/09_hypotenuse.py +++ b/2-variables/09_hypotenuse.py @@ -1,4 +1,4 @@ -# Pythagorean Theroem 📐 +# Pythagorean Theorem 📐 # Codédex a = int(input("Enter a: ")) From ed5f96abbcfa3ad0e53c520ce0231123fe02995f Mon Sep 17 00:00:00 2001 From: Milan Date: Fri, 11 Oct 2024 13:43:42 +0200 Subject: [PATCH 55/73] Fixed typo in solution file 27_bucket_list.py. --- 5-lists/27_bucket_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-lists/27_bucket_list.py b/5-lists/27_bucket_list.py index 0c4e2f8..f4dcfa7 100644 --- a/5-lists/27_bucket_list.py +++ b/5-lists/27_bucket_list.py @@ -2,7 +2,7 @@ # Codédex things_to_do = [ - '🚀 Build a menaingful product for everyone.', + '🚀 Build a meaningful product for everyone.', '⛰ Try out hiking and mountain biking.', '🌏 Visit at least 10 countries in my lifetime.', '🎸 Produce an original song.', From 30687b1078a8cc712a7b22124739b784dba25405 Mon Sep 17 00:00:00 2001 From: Milan Date: Fri, 11 Oct 2024 13:51:12 +0200 Subject: [PATCH 56/73] Fixed typo in projects.md. --- projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects.md b/projects.md index 20fd964..6e66f9f 100644 --- a/projects.md +++ b/projects.md @@ -4,7 +4,7 @@ - 🥠 Fortune Cookie - 🎲 Dice Rolling Simulator -- 🫱 Rock Paper Scisssors +- 🫱 Rock Paper Scissors - 🫱 Rock Paper Scissors Lizard Spark - 🤑 Who Wants to Be a Millionaire - ❓ Quiz Game From 9455e940956343ae1a78a0fa811ae9ea29e6b14c Mon Sep 17 00:00:00 2001 From: Thor Christensen Date: Wed, 16 Oct 2024 08:26:51 +0200 Subject: [PATCH 57/73] =?UTF-8?q?Fix=20Charizard's=20Pok=C3=A9dex=20number?= =?UTF-8?q?=20from=203=20to=206=20in=20both=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 7-classes-objects/38_pokedex_1.py | 2 +- 7-classes-objects/38_pokedex_2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/7-classes-objects/38_pokedex_1.py b/7-classes-objects/38_pokedex_1.py index 6b533ee..f11d4a1 100644 --- a/7-classes-objects/38_pokedex_1.py +++ b/7-classes-objects/38_pokedex_1.py @@ -31,7 +31,7 @@ def display_details(self): # Pokémon objects pikachu = Pokemon(25, 'Pikachu', ['Electric'], 'It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.', True) -charizard = Pokemon(3, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', False) +charizard = Pokemon(6, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', False) gyarados = Pokemon(130, 'Gyarados', ['Water', 'Flying'], 'It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.', False) pikachu.speak() diff --git a/7-classes-objects/38_pokedex_2.py b/7-classes-objects/38_pokedex_2.py index b483644..91c3311 100644 --- a/7-classes-objects/38_pokedex_2.py +++ b/7-classes-objects/38_pokedex_2.py @@ -35,7 +35,7 @@ def display_details(self): # Pokémon objects pikachu = Pokemon(25, 'Pikachu', ['Electric'], 'It has small electric sacs on both its cheeks. If threatened, it looses electric charges from the sacs.', 25, 'Kanto', True) -charizard = Pokemon(3, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', 36, 'Kanto', False) +charizard = Pokemon(6, 'Charizard', ['Fire', 'Flying'], 'It spits fire that is hot enough to melt boulders. It may cause forest fires by blowing flames.', 36, 'Kanto', False) gyarados = Pokemon(130, 'Gyarados', ['Water', 'Flying'], 'It has an extremely aggressive nature. The HYPER BEAM it shoots from its mouth totally incinerates all targets.', 57, 'Kanto', False) pikachu.speak() From 91af2af610e24630d1e0d958a1ddc28b226f1f20 Mon Sep 17 00:00:00 2001 From: Bruno Viola <99220989+BrunoViola@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:54:33 -0300 Subject: [PATCH 58/73] Fix: List in the solution differs from the instructions. I noticed that the instructions in section 24, 'Inventory,' mention a list named 'lego_parts,' but here on GitHub, the list used is 'airplane_toys. --- 5-lists/24_inventory.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/5-lists/24_inventory.py b/5-lists/24_inventory.py index 99f001c..1c1cb5a 100644 --- a/5-lists/24_inventory.py +++ b/5-lists/24_inventory.py @@ -1,7 +1,7 @@ # Inventory 📦 # Codédex -airplane_toys = [ 898, 732, 543, 878 ] +lego_parts = [8980, 7323, 5343, 82700, 92232, 1203, 7319, 8903, 2328, 1279, 679, 589] -print(min(airplane_toys)) -print(max(airplane_toys)) +print(min(lego_parts)) +print(max(lego_parts)) From 4e99491c6d36971c0de4899cf44f82feca0a8423 Mon Sep 17 00:00:00 2001 From: Milan Date: Tue, 22 Oct 2024 21:41:13 +0200 Subject: [PATCH 59/73] Added missing standard header. --- 1-hello-world/02_hello_world.py | 3 +++ 1-hello-world/03_pattern.py | 3 +++ 1-hello-world/04_initials.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/1-hello-world/02_hello_world.py b/1-hello-world/02_hello_world.py index 60f08aa..d66b420 100644 --- a/1-hello-world/02_hello_world.py +++ b/1-hello-world/02_hello_world.py @@ -1 +1,4 @@ +# Hello World 🌎 +# Codédex + print('Hello world!') diff --git a/1-hello-world/03_pattern.py b/1-hello-world/03_pattern.py index 1ed538d..86d5f65 100644 --- a/1-hello-world/03_pattern.py +++ b/1-hello-world/03_pattern.py @@ -1,3 +1,6 @@ +# Pattern 📊 +# Codédex + print(' 1') print(' 2 3') print(' 4 5 6') diff --git a/1-hello-world/04_initials.py b/1-hello-world/04_initials.py index 57a2076..c35b1e3 100644 --- a/1-hello-world/04_initials.py +++ b/1-hello-world/04_initials.py @@ -1,3 +1,6 @@ +# Initials ℹ️ +# Codédex + # Fun fact: My high school band Attica was signed to an indie record label. print(' SSS L ') From 9df24ed98456fc67e09872b868005e209d33597e Mon Sep 17 00:00:00 2001 From: Bruno Viola <99220989+BrunoViola@users.noreply.github.com> Date: Wed, 23 Oct 2024 02:04:35 +0000 Subject: [PATCH 60/73] fix: add missing print(vars()) --- 7-classes-objects/35_bobs_burgers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/7-classes-objects/35_bobs_burgers.py b/7-classes-objects/35_bobs_burgers.py index c174dcb..68264cc 100644 --- a/7-classes-objects/35_bobs_burgers.py +++ b/7-classes-objects/35_bobs_burgers.py @@ -24,3 +24,7 @@ class Restaurant: baekjeong.type = 'Korean BBQ' baekjeong.rating = 4.4 baekjeong.delivery = False + +print(vars(bobs_burgers)) +print(vars(katz_deli)) +print(vars(baekjeong)) \ No newline at end of file From d91ac53c3bd3ad08200653b2e8c902c087218adc Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Fri, 25 Oct 2024 17:39:56 -0400 Subject: [PATCH 61/73] Update 25_reading_list.py --- 5-lists/25_reading_list.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/5-lists/25_reading_list.py b/5-lists/25_reading_list.py index 9a9d646..07ace1e 100644 --- a/5-lists/25_reading_list.py +++ b/5-lists/25_reading_list.py @@ -1,16 +1,16 @@ # Reading List 📚 # Codédex -books = ['Zero to One', - 'The Lean Startup', +books = ['Harry Potter', + '1984', + 'The Fault in Our Stars', 'The Mom Test', - 'Made to Stick', 'Life in Code'] print(books) -books.append('Zero to Sold') -books.remove('Zero to One') -books.pop(0) +books.append('Pachinko') +books.remove('The Fault in Our Stars') +books.pop(1) print(books) From 434a509938f85806259095e8b2a6fecc7d9d251f Mon Sep 17 00:00:00 2001 From: Bruno Viola <99220989+BrunoViola@users.noreply.github.com> Date: Sat, 26 Oct 2024 22:33:28 -0300 Subject: [PATCH 62/73] fix: correct attributes name to match instructions I noticed that the names of the attributes in the sollution were different from the instructions given in class 34, Restaurants. Then, I corrected this to ensure consistency. --- 7-classes-objects/34_restaurants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/7-classes-objects/34_restaurants.py b/7-classes-objects/34_restaurants.py index b8e1299..3986bfe 100644 --- a/7-classes-objects/34_restaurants.py +++ b/7-classes-objects/34_restaurants.py @@ -3,6 +3,6 @@ class Restaurant: name = '' - description = '' + category = '' rating = 0.0 - deliver = True + delivery = True From 422e615d80f2be29c9d6c661cefc2a0eb16e1d82 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 13 Nov 2024 23:56:58 -0500 Subject: [PATCH 63/73] Update 16_sorting_hat_1.py --- 3-control-flow/16_sorting_hat_1.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/3-control-flow/16_sorting_hat_1.py b/3-control-flow/16_sorting_hat_1.py index c1547dc..f9747fc 100644 --- a/3-control-flow/16_sorting_hat_1.py +++ b/3-control-flow/16_sorting_hat_1.py @@ -77,13 +77,13 @@ print("Hufflepuff: ", hufflepuff) print("Slytherin: ", slytherin) -most_points = max(gryffindor, ravenclaw, hufflepuff, slytherin) # We'll learn about max() in the Functions chapter +# Bonus Part -if gryffindor == most_points: +if gryffindor >= ravenclaw and gryffindor >= hufflepuff and gryffindor >= slytherin: print('🦁 Gryffindor!') -elif ravenclaw == most_points: +elif ravenclaw >= hufflepuff and ravenclaw >= slytherin: print('🦅 Ravenclaw!') -elif hufflepuff == most_points: +elif hufflepuff >= slytherin: print('🦡 Hufflepuff!') else: print('🐍 Slytherin!') From d0e9e51325c3892808efb9fbdd345bf29c30ce1c Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Wed, 13 Nov 2024 23:57:42 -0500 Subject: [PATCH 64/73] Update 16_sorting_hat_2.py --- 3-control-flow/16_sorting_hat_2.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/3-control-flow/16_sorting_hat_2.py b/3-control-flow/16_sorting_hat_2.py index 55692c1..be56f5c 100644 --- a/3-control-flow/16_sorting_hat_2.py +++ b/3-control-flow/16_sorting_hat_2.py @@ -77,11 +77,15 @@ print("Hufflepuff: ", hufflepuff) print("Slytherin: ", slytherin) -if gryffindor >= ravenclaw and gryffindor >= hufflepuff and gryffindor >= slytherin: +# Bonus Part + +most_points = max(gryffindor, ravenclaw, hufflepuff, slytherin) # We'll learn about the max() function in Chapter 6 + +if gryffindor == most_points: print('🦁 Gryffindor!') -elif ravenclaw >= hufflepuff and ravenclaw >= slytherin: +elif ravenclaw == most_points: print('🦅 Ravenclaw!') -elif hufflepuff >= slytherin: +elif hufflepuff == most_points: print('🦡 Hufflepuff!') else: - print('🐍 Slytherin!') \ No newline at end of file + print('🐍 Slytherin!') From e6ff9020c826a69e6c6863bcbdd3816cb7bd4b3e Mon Sep 17 00:00:00 2001 From: Julien Kris <65314071+jules-kris@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:22:38 -0500 Subject: [PATCH 65/73] Update 02_hello_world.py --- 1-hello-world/02_hello_world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-hello-world/02_hello_world.py b/1-hello-world/02_hello_world.py index d66b420..0ebb3e7 100644 --- a/1-hello-world/02_hello_world.py +++ b/1-hello-world/02_hello_world.py @@ -1,4 +1,4 @@ # Hello World 🌎 # Codédex -print('Hello world!') +print('Hello World!') From 6a3ac446daee948947abdf9f4f9f0e02bdc37746 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Mon, 3 Mar 2025 01:50:51 -0500 Subject: [PATCH 66/73] Update 02_hello_world.py --- 1-hello-world/02_hello_world.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/1-hello-world/02_hello_world.py b/1-hello-world/02_hello_world.py index 0ebb3e7..73fb7c3 100644 --- a/1-hello-world/02_hello_world.py +++ b/1-hello-world/02_hello_world.py @@ -1,4 +1 @@ -# Hello World 🌎 -# Codédex - print('Hello World!') From d345860b0e1beba64cc18fff369bf834c678422c Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Mon, 3 Mar 2025 01:51:01 -0500 Subject: [PATCH 67/73] Update 03_pattern.py --- 1-hello-world/03_pattern.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/1-hello-world/03_pattern.py b/1-hello-world/03_pattern.py index 86d5f65..1ed538d 100644 --- a/1-hello-world/03_pattern.py +++ b/1-hello-world/03_pattern.py @@ -1,6 +1,3 @@ -# Pattern 📊 -# Codédex - print(' 1') print(' 2 3') print(' 4 5 6') From 64efdc5800805bee8ce49b172fde32eb68dd3838 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Mon, 3 Mar 2025 01:51:15 -0500 Subject: [PATCH 68/73] Update 04_initials.py --- 1-hello-world/04_initials.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/1-hello-world/04_initials.py b/1-hello-world/04_initials.py index c35b1e3..57a2076 100644 --- a/1-hello-world/04_initials.py +++ b/1-hello-world/04_initials.py @@ -1,6 +1,3 @@ -# Initials ℹ️ -# Codédex - # Fun fact: My high school band Attica was signed to an indie record label. print(' SSS L ') From 8f9562cb9b26cac7783a8ac53f7e3b23871d41f1 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sun, 13 Apr 2025 16:40:23 -0400 Subject: [PATCH 69/73] Update 18_guess_number.py --- 4-loops/18_guess_number.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/4-loops/18_guess_number.py b/4-loops/18_guess_number.py index cfbb6c0..1597cad 100644 --- a/4-loops/18_guess_number.py +++ b/4-loops/18_guess_number.py @@ -5,7 +5,7 @@ tries = 0 while guess != 6 and tries < 5: - guess = int(input('Guess the number: ')) + guess = int(input('Guess the number: ')) tries = tries + 1 if guess != 6: From 1cbab24fca2015820051f42834cd76008f3f6cf2 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Sun, 20 Apr 2025 17:38:00 -0400 Subject: [PATCH 70/73] Update 16_sorting_hat_1.py --- 3-control-flow/16_sorting_hat_1.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/3-control-flow/16_sorting_hat_1.py b/3-control-flow/16_sorting_hat_1.py index f9747fc..9355579 100644 --- a/3-control-flow/16_sorting_hat_1.py +++ b/3-control-flow/16_sorting_hat_1.py @@ -20,11 +20,11 @@ answer = int(input('Enter answer (1-2): ')) if answer == 1: - gryffindor += 1 - ravenclaw += 1 + gryffindor = gryffindor + 1 + ravenclaw = ravenclaw + 1 elif answer == 2: - hufflepuff += 1 - slytherin +=1 + hufflepuff = hufflepuff + 1 + slytherin = slytherin + 1 else: print('Wrong input.') @@ -40,13 +40,13 @@ answer = int(input('Enter your answer (1-4): ')) if answer == 1: - hufflepuff += 2 + hufflepuff = hufflepuff + 2 elif answer == 2: - slytherin += 2 + slytherin = slytherin + 2 elif answer == 3: - ravenclaw += 2 + ravenclaw = ravenclaw + 2 elif answer == 4: - gryffindor += 2 + gryffindor = gryffindor + 2 else: print('Wrong input.') @@ -62,13 +62,13 @@ answer = int(input('Enter your answer (1-4): ')) if answer == 1: - slytherin += 4 + slytherin = slytherin + 4 elif answer == 2: - hufflepuff += 4 + hufflepuff = hufflepuff + 4 elif answer == 3: - ravenclaw +=4 + ravenclaw = ravenclaw + 4 elif answer == 4: - gryffindor += 4 + gryffindor = gryffindor + 4 else: print('Wrong input.') From c0ef0d4921767b0311be25cb8cc4c85eb2c2e054 Mon Sep 17 00:00:00 2001 From: Ellie Popoca Date: Fri, 6 Jun 2025 01:17:25 -0400 Subject: [PATCH 71/73] Update 30_rocket.py --- 6-functions/30_rocket.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/6-functions/30_rocket.py b/6-functions/30_rocket.py index 306c2eb..d928b41 100644 --- a/6-functions/30_rocket.py +++ b/6-functions/30_rocket.py @@ -2,7 +2,7 @@ # Codédex def distance_to_miles(distance): - return distance / 1.609 + miles = distance / 1.609 + print(miles) -answer = distance_to_miles(10000) -print(answer) +distance_to_miles(10000) From 2499d8fb1c7ce5d753af684128a5be42d5a9470d Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Mon, 9 Jun 2025 17:05:04 -0400 Subject: [PATCH 72/73] Create 02_setting_up.py --- 1-hello-world/02_setting_up.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 1-hello-world/02_setting_up.py diff --git a/1-hello-world/02_setting_up.py b/1-hello-world/02_setting_up.py new file mode 100644 index 0000000..4ac8144 --- /dev/null +++ b/1-hello-world/02_setting_up.py @@ -0,0 +1,3 @@ +# Write code below 💖 + +print('Hi') From 5595ce77f1d7fa7740c2be7d1e86fcef2b1ef6c4 Mon Sep 17 00:00:00 2001 From: Sonny Li Date: Mon, 9 Jun 2025 17:05:16 -0400 Subject: [PATCH 73/73] Rename 02_setting_up.py to 01_setting_up.py --- 1-hello-world/{02_setting_up.py => 01_setting_up.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 1-hello-world/{02_setting_up.py => 01_setting_up.py} (100%) diff --git a/1-hello-world/02_setting_up.py b/1-hello-world/01_setting_up.py similarity index 100% rename from 1-hello-world/02_setting_up.py rename to 1-hello-world/01_setting_up.py