From 13c38af7364587c61987143d26fa83e91f59999a Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 27 May 2020 21:28:05 +0900 Subject: [PATCH 1/5] [Python #5] create e28.py --- kjg/python-the-hard-way/e28.py | 19 +++++++++++++++++++ kjg/python.org | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 kjg/python-the-hard-way/e28.py diff --git a/kjg/python-the-hard-way/e28.py b/kjg/python-the-hard-way/e28.py new file mode 100644 index 0000000..d4a116a --- /dev/null +++ b/kjg/python-the-hard-way/e28.py @@ -0,0 +1,19 @@ +#True and True -> True +#False and True -> False +#1 == 1 and 2 == 1 -> False +#"test" == "test" -> True +#1 == 1 or 2 != 1 -> True +#True and 1 == 1 -> True +#False and 0 != 0 -> False +#True or 1 == 1 -> True +#"test" == "testing" -> False +#1 != 0 and 2 == 1 -> False +#"test" != "testing" -> True +#"test" == 1 -> False +#not (True and False) -> True +#not(1 == 1 and 0 != 1) -> False +#not (10 == 1 or 1000 == 1000) -> False +#not(1 != 10 or 3 == 4) -> False +#not ("testing" == "testing" and "Zed" == "Cool Guy") -> True +#1 == 1 and (not("testing" == 1 or 1 == 0)) -> True +#"chunky" == "bacon" and (not (3 == 4 or 3 == 3)) -> Fasle diff --git a/kjg/python.org b/kjg/python.org index 301bb4c..674907e 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -110,3 +110,8 @@ practice function and print practice import function **** ex26 practice debug code +*** Python #4: +**** ex27 +How to use True and Flase +**** ex28 +How to use Boolean From 885832e4a25089cabb07d176a90342bc19f20bd2 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 27 May 2020 21:38:55 +0900 Subject: [PATCH 2/5] [Python #5] create e29.py --- kjg/python-the-hard-way/e29.py | 35 ++++++++++++++++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 kjg/python-the-hard-way/e29.py diff --git a/kjg/python-the-hard-way/e29.py b/kjg/python-the-hard-way/e29.py new file mode 100644 index 0000000..a257dc6 --- /dev/null +++ b/kjg/python-the-hard-way/e29.py @@ -0,0 +1,35 @@ +people = 21 +cats = 33 +dogs = 14 + + +if people < cats: + print("Too many cats! The world is doomed!") + +if people > cats: + print("Not many cats! The world is saved!") + +if people < dogs: + print("The world is drooled on!") + +if people > dogs: + print("The world is dry!") + +if people != dogs: + print("People are not dogs.") + + +dogs += 5 + + +if people >= dogs: + print("People are greater than or equal to dogs.") + + +if people <= dogs: + print("People are less than or equal to dogs.") + + +if people == dogs: + print("People are dogs.") + diff --git a/kjg/python.org b/kjg/python.org index 674907e..d3b4b36 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -115,3 +115,5 @@ practice debug code How to use True and Flase **** ex28 How to use Boolean +**** ex29 +How to use if-statement From 34322bf08d52a8d54046bf89c8173f3d0521a543 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 27 May 2020 21:52:04 +0900 Subject: [PATCH 3/5] [Python #5] create e30.py --- kjg/python-the-hard-way/e30.py | 27 +++++++++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 kjg/python-the-hard-way/e30.py diff --git a/kjg/python-the-hard-way/e30.py b/kjg/python-the-hard-way/e30.py new file mode 100644 index 0000000..ca2228f --- /dev/null +++ b/kjg/python-the-hard-way/e30.py @@ -0,0 +1,27 @@ +people = 21 +cars = 15 +trucks = 30 + +if cars > people: + print("We should take the cars.") +elif cars < people: + print("We should not take the cars.") +else: + print("We can't decide.") + + +if trucks > cars: + print("That's too many trucks.") +elif trucks < cars: + print("Maybe we could take the trucks.") +else: + print("We still can't decide.") +if people > trucks: + print("Alright, let's just take the trucks.") +else: + print("Fine, let's stay home then.") + +if cars > people or trucks < cars: + print("cars are many") +else: + print("trucks or people is bigger") diff --git a/kjg/python.org b/kjg/python.org index d3b4b36..71e23c9 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -117,3 +117,5 @@ How to use True and Flase How to use Boolean **** ex29 How to use if-statement +**** ex30 +How to use if-else From 5230394ef8ccf8f03f9a060be6bc5a45631e7202 Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 27 May 2020 22:03:11 +0900 Subject: [PATCH 4/5] [Python #5] update e30.py --- kjg/python-the-hard-way/e30.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/kjg/python-the-hard-way/e30.py b/kjg/python-the-hard-way/e30.py index ca2228f..a790c43 100644 --- a/kjg/python-the-hard-way/e30.py +++ b/kjg/python-the-hard-way/e30.py @@ -2,26 +2,27 @@ people = 21 cars = 15 trucks = 30 -if cars > people: - print("We should take the cars.") -elif cars < people: - print("We should not take the cars.") +if cars > people: #check cars are bigger than people + print("We should take the cars.") #print if cars are bigger than people +elif cars < people: #check cars are smaller than people + print("We should not take the cars.") #print if cars are smaller than people else: - print("We can't decide.") + print("We can't decide.") #print if cars are same with people -if trucks > cars: - print("That's too many trucks.") -elif trucks < cars: - print("Maybe we could take the trucks.") +if trucks > cars: #check trucks are bigger than cars + print("That's too many trucks.") #print if trucks are bigger than cars +elif trucks < cars: #check trucks are smaller than cars + print("Maybe we could take the trucks.") #print if trucks are smaller than cars else: - print("We still can't decide.") -if people > trucks: - print("Alright, let's just take the trucks.") + print("We still can't decide.") #print if trucks are same with cars + +if people > trucks: #check people are bigger than trucks + print("Alright, let's just take the trucks.") #print if people are bigger than trucks else: - print("Fine, let's stay home then.") + print("Fine, let's stay home then.") #print if people are bigger than trucks -if cars > people or trucks < cars: - print("cars are many") +if cars > people or trucks < cars: #check cars are bigger than people or trucks are smaller than cars + print("cars are many") #print if cars are bigger than people or trucks are smaller than cars else: - print("trucks or people is bigger") + print("trucks or people is bigger") #print not (cars > people or trucks < cars) From 16f3a7714b5c5cfeedfd9551a529d796f800061f Mon Sep 17 00:00:00 2001 From: kjg Date: Wed, 27 May 2020 22:30:01 +0900 Subject: [PATCH 5/5] [Python #5] create e31.py --- kjg/python-the-hard-way/e31.py | 48 ++++++++++++++++++++++++++++++++++ kjg/python.org | 2 ++ 2 files changed, 50 insertions(+) create mode 100644 kjg/python-the-hard-way/e31.py diff --git a/kjg/python-the-hard-way/e31.py b/kjg/python-the-hard-way/e31.py new file mode 100644 index 0000000..e320fc5 --- /dev/null +++ b/kjg/python-the-hard-way/e31.py @@ -0,0 +1,48 @@ +print("""You enter a dark room with two doors. +Do you go through door #1 or door #2?""") + +door = input("> ") + +if door == "1": + print("There's a giant bear here eating a cheese cake.") + print("What do you do?") + print("1. Take the cake.") + print("2. Scream at the bear.") + + bear = input("> ") + + if bear == "1": + print("The bear eats your face off. Good job!") + elif bear == "2": + print("The bear eats your legs off. Good job!") + else: + print(f"Well, doing {bear} is probably better.") + print("Bear runs away.") + +elif door == "2": + print("You stare into the endless abyss at Cthulhu's retina.") + print("1. Blueberries.") + print("2. Yellow jacket clothespins.") + print("3. Understanding revolvers yelling melodies.") + + insanity = input("> ") + + if insanity == "1" or insanity == "2": + print("Your body survives powered by a mind of jello.") + print("Good job!") + else: + print("The insanity rots your eyes into a pool of muck.") + print("Good job!") +else: + print("You stumble around and fall on a knife and die. Good job!") + + +if door == "3": + print(f"you choose {door}") + if int(door) in range(1, 10): + print("in 1 between 10") + else: + print("not in between 10") +else: + print(f"you choose {door}") + diff --git a/kjg/python.org b/kjg/python.org index 71e23c9..400c366 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -119,3 +119,5 @@ How to use Boolean How to use if-statement **** ex30 How to use if-else +**** ex31 +How to use if, elif