Today's Agenda
4:30 - 4:45PM: Log on & Ice breakers: If you were to be reincarnated as an animal, what would it be and why?
4:45 - 5:05PM: Definitions
Libraries: A Python library is a reusable chunk of code that you may want to include in your programs/ projects.
Input(): The input() function allows user input.
elif: The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".
Indentation: Python relies on indentation (whitespace at the beginning of a line) to define scope in the code. Other programming languages often use curly-brackets for this purpose.
5:05 - 5:10 PM: Bio Break & Guided Python instruction
5:10 - 5:30PM: Guided Python instruction
5:30 - 6:00 PM: Save & Share!
In this course, you will learn the basics of Python programming. We will meet every Tuesday at 4:30pm to 6:00pm. You don't need any previous programming experiences and all you need to code in Python is a web browser (www.replit.com). Mr. Steven will teach you all the core aspects of the Python programming and I will simplify the more complex topics.
Today we will be creating our own adventure story in Python.
import os #very useful for clearing the screen or other os commands
import random #generate random stuff
name = input("Name Please: ") #We’ll use this to get the name from the user
nickname = input("Nickname: ")
print("Hello and welcome " + name)
print("Long ago, there was a magical meal known as Summuh and Spich Atip") #We can drop a line by making a new print statement, or we can use the escape code \n
print("It was said that this meal had the power to save lives, restore peace, and stop evil\nBecuase it was so powerful, it was hidden away on a mountain that could not be climbed\nBut it’s power brought unwanted attention, and a great war broke out.\nFinally, the leaders of the good side chose a single hero to go and find the Summah and Spich Atip, that hero was " + name + "\n so " + nickname + " headed out to find this great power, and stop the war…")
print("After hiking through the wastelands for a long time, you come to a massive ravine, there is only a single way across\nA rickety old bridge, taking that could be very dangerous, but… maybe you could jump across?")
choice = input("[1] Take the bridge [2] Try and jump over")
#Now we check to see what the player chose
if choice == "1": # see how the number is in a string format
print("You slowly walk across the bride, it creakes ominously, then suddenly breaks! You flail through the air before hitting the ground a thousand feet below. Judging by the fact that you hit the ground with the equivalent force of being hit by a cement truck moving at 125 miles an hour, you are dead…")
#The player lost, so now we’ll boot them out of the program with the exit command
exit()
#Then we check to see if they made the other choice, we can do with with else if, written as elif
elif choice == "2":
print("You make the jump! You see a feather hit the bridge, the weight breakes it and sends it to the bottom of the ravine\nGood thing you didn’t use that bridge.")
#Now we can continue the story
print("A few more hours of travel and you come to the unclimbable mountain")
choice == input("[1] Give up [2] Try and climb the mountain")
if choice == "1":
print("You gave up and lost…")
#now we exit them again
exit()
elif choice == "2":
print("you continue up the mountain. Climbing is hard, but finally you reach the top.\nTo your surprise there is a man standing at the top of the mountain, he is very old.")
print("Old Man: Hey " + nickname)
print("You: How do you know my name!?!")
print("Old Man: Because you have a name tag on…")
print("You: Oh, well, were is the Summuh and Spich Atip?")
print("Old Man: Summuh and Spich Atip? You must mean the Pita Chips and Hummus")
print("You: Pita…chips…humus, what power do those have?")
print("Old Man: Pretty simple kid, their organic…")
input("Press enter to continue")
#Now let’s clear the screen
os.system("clear")
print("YOU WON!!!")
Top right "Invite"
Select Generate a join link
Copy your link and share it via Zoom Chat!
import os #very useful for clearing the screen or other os commands
import random #generate random stuff
name = input("Name Please: ") #We’ll use this to get the name from the user
nickname = input("Nickname: ")
print("Hello and welcome " + name)
print("Long ago, there was a magical meal known as Summuh and Spich Atip") #We can drop a line by making a new print statement, or we can use the escape code \n
print("It was said that this meal had the power to save lives, restore peace, and stop evil\nBecuase it was so powerful, it was hidden away on a mountain that could not be climbed\nBut it’s power brought unwanted attention, and a great war broke out.\nFinally, the leaders of the good side chose a single hero to go and find the Summah and Spich Atip, that hero was " + name + "\n so " + nickname + " headed out to find this great power, and stop the war…")
print("After hiking through the wastelands for a long time, you come to a massive ravine, there is only a single way across\nA rickety old bridge, taking that could be very dangerous, but… maybe you could jump across?")
choice = input("[1] Take the bridge [2] Try and jump over")
#Now we check to see what the player chose
if choice == "1": # see how the number is in a string format
print("You slowly walk across the bride, it creakes ominously, then suddenly breaks! You flail through the air before hitting the ground a thousand feet below. Judging by the fact that you hit the ground with the equivalent force of being hit by a cement truck moving at 125 miles an hour, you are dead…")
#The player lost, so now we’ll boot them out of the program with the exit command
exit()
#Then we check to see if they made the other choice, we can do with with else if, written as elif
elif choice == "2":
print("You make the jump! You see a feather hit the bridge, the weight breakes it and sends it to the bottom of the ravine\nGood thing you didn’t use that bridge.")
#Now we can continue the story
print("A few more hours of travel and you come to the unclimbable mountain")
choice == input("[1] Give up [2] Try and climb the mountain")
if choice == "1":
print("You gave up and lost…")
#now we exit them again
exit()
elif choice == "2":
print("you continue up the mountain. Climbing is hard, but finally you reach the top.\nTo your surprise there is a man standing at the top of the mountain, he is very old.")
print("Old Man: Hey " + nickname)
print("You: How do you know my name!?!")
print("Old Man: Because you have a name tag on…")
print("You: Oh, well, were is the Summuh and Spich Atip?")
print("Old Man: Summuh and Spich Atip? You must mean the Pita Chips and Hummus")
print("You: Pita…chips…humus, what power do those have?")
print("Old Man: Pretty simple kid, their organic…")
input("Press enter to continue")
#Now let’s clear the screen
os.system("clear")
print("YOU WON!!!")