From e8f8aed3f520097aa901c0415213ae0215f83b79 Mon Sep 17 00:00:00 2001 From: Steve De Jongh Date: Wed, 27 Oct 2021 20:11:34 +0200 Subject: [PATCH 1/4] Added String.format example --- examples/string_format.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 examples/string_format.py diff --git a/examples/string_format.py b/examples/string_format.py new file mode 100644 index 0000000..777c018 --- /dev/null +++ b/examples/string_format.py @@ -0,0 +1,6 @@ +fname = "John" +lname = "Doe" + +bond_string = "My name is {lastname}, {firstname} {lastname}".format(firstname=fname, lastname=lname) + +print(bond_string) From 529d797553cde4ced85f1729a28123106b333033 Mon Sep 17 00:00:00 2001 From: Steve De Jongh Date: Thu, 28 Oct 2021 09:16:46 +0200 Subject: [PATCH 2/4] String.format basic placeholders --- examples/string_format.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/string_format.py b/examples/string_format.py index 777c018..554a100 100644 --- a/examples/string_format.py +++ b/examples/string_format.py @@ -1,3 +1,15 @@ +# Basic placeholders + +ingredient = "sugar" +quantity = "500g" + +ingredient_string = "- {}: {}".format(ingredient, quantity) + +print(ingredient_string) + + +# Named placeholders + fname = "John" lname = "Doe" From 3492f07e070430db4cd5769ef49dd73ea61cd7f9 Mon Sep 17 00:00:00 2001 From: waldek Date: Thu, 28 Oct 2021 11:16:13 +0200 Subject: [PATCH 3/4] adds image to adventure game --- .gitignore | 1 + assets/text_based_adventure_game.dia | 1003 ++++++++++++++++++++++++++ assets/text_based_adventure_game.png | Bin 0 -> 24695 bytes learning_python3.md | 2 +- 4 files changed, 1005 insertions(+), 1 deletion(-) create mode 100644 assets/text_based_adventure_game.dia create mode 100644 assets/text_based_adventure_game.png diff --git a/.gitignore b/.gitignore index 733a58d..06a6c88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.swp *.pdf *.docx .~lock* diff --git a/assets/text_based_adventure_game.dia b/assets/text_based_adventure_game.dia new file mode 100644 index 0000000..92c4e29 --- /dev/null +++ b/assets/text_based_adventure_game.dia @@ -0,0 +1,1003 @@ + + + + + + + + + + + + + #A4# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #You're in a cross section. +Do you go left or right?# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #Down this hall you encounter a bear. +It runs towards you. +Do you fight it?# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #A wizard appears who asks +you the meaning of life...# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #game over# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #You find some mushrooms. +Do you eat them?# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #You starve to dead...# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #The bear counter attacks! +You die...# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #That's right! He promotes you +to wizard level!# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #The wizard curses you to a life +of damnation# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #you win# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/text_based_adventure_game.png b/assets/text_based_adventure_game.png new file mode 100644 index 0000000000000000000000000000000000000000..15384db0678fdb24faa07dea90972fea4d7055fd GIT binary patch literal 24695 zcmeFZ2UL`4wl!QT2qIBX5G1H10RfSmQGy^6BuW$z1SCf(k^+K)fFcM=2B8Q7k~1hu z5JWFhhKrkTWrKQyG$IK4g)27fW zn_OZ$Lc-6>pQcw+SjlffddK(JHH0lm-7)#P(_f-u=boKU@_qg#N>tUPh{eV=mV9K7MK&nKn9H^>Dj6F)u~09as--$a{!XKn!5Gb^GjVk;eF`0!REm$g>m8qw zsg;G)>eT79&8Z4!l@Ei~QPj>89}+vVz}ALZotcL>5HYvua9arm&t1iR zVLj;^C3gsc(2)*-J1Tg51{Z-aCliAEZ9V5e0be3B%8Ecp1~sT65D!j0PliulJonE( zkifFF)#4rZ>Q%aEflgLiTU%2km#rETiNx+=wtjgZrR0?>SB#8|c8ccs>YkofyLmH7 zbTkUFfiFbR`r@r&_5S;ZM|6vu29Mt3otn#p zxa;8=*#QT|2UQQw;7-aPC85((QCW;0+D*;Km_{p043yZ96j@_94XZ>ww^!f4fB){? zyRDT8U5-Cy zbt$>3YA|=VF@n8%dz#%8W7_ocMilq(Lp-``*RBcLfA=%l>de%NR%A9bG)!(QF|H** z1zVb%M+w*(+_^LQ;LwrpBO@&_LMD_w@Ee=W^3nX+xAN=EdAGN=9{KrIY)@yhv7c0m zx3;o!>T{{@SzcaNiWQECjJ(TBou8Ly75XHTVL(U)5%Ub;R9r+{2Y0~2#3Umv4eMkO z_6A<4IAlg{ZkrW9{CRV%h!*E53X0XOiTI|b0AkwZrKRVQuJip{dmBSdP0TMY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~7aPm4Pz= literal 0 HcmV?d00001 diff --git a/learning_python3.md b/learning_python3.md index eacb6d5..0657c65 100644 --- a/learning_python3.md +++ b/learning_python3.md @@ -411,7 +411,7 @@ else: # A text based adventure game -TODO mini text based adventure game to point out the complexity of conditional logic and flow control +![adventure game](./assets/text_based_adventure_game.png) # Creating your own functions From eeb100e485208757a025cc2b220a144f358a5c00 Mon Sep 17 00:00:00 2001 From: waldek Date: Thu, 28 Oct 2021 11:35:48 +0200 Subject: [PATCH 4/4] adds textbased game code --- learning_python3.md | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/learning_python3.md b/learning_python3.md index 0657c65..d939a94 100644 --- a/learning_python3.md +++ b/learning_python3.md @@ -411,8 +411,61 @@ else: # A text based adventure game +We can use conditional logic to create quite elaborate decision processes. +Let's build a mini text based adventure game. +Granted it's not a *tripple A* game but it will train your `if` and `else` skills plus it will highlight some issues we'll overcome in the next section. +Consider the diagram below. + ![adventure game](./assets/text_based_adventure_game.png) +```python3 +answer = input("You're at a cross section. Do you go left or right?") +if answer.startswith("l"): + answer = input("Down this hall you encounter a bear. Do you fight it?") + if answer.startswith("y"): + print("The bear counter attack! He kills you") + print("game over!") + exit(0) + elif answer.startswith("n"): + print("It's a friendly bear! He transforms into a wizard!") + answer = input("The wizard asks you if you know the meaning of life?") + if answer == "42": + print("He knods approuvingly and upgrades you to wizard status!") + print("You win!") + exit(0) + else: + print("He shakes his head in disbelief. You fool!") + print("game over!") + else: + print("that's not a valid choice...") + print("game over!") + exit(0) +elif answer.startswith("r"): + answer = input("Down this hall you find some mushrooms. Do you eat them?") + if answer.startswith("n"): + print("You starve to dead...") + print("game over!") + exit(0) + elif answer.startswith("y"): + print("A wizard apprears out of thin air!") + answer = input("The wizard asks you if you know the meaning of life?") + if answer == "42": + print("He knods approuvingly and upgrades you to wizard status!") + print("You win!") + exit(0) + else: + print("He shakes his head in disbelief. You fool!") + print("game over!") + else: + print("that's not a valid choice...") + print("game over!") + exit(0) + pass +else: + print("game over!") + exit(0) +``` + # Creating your own functions ## Functions that *do* something