0% found this document useful (0 votes)
245 views

Programming HW

The document contains code for three different Python programs: 1) A word game that takes user input for adjectives and nouns and prints them in a poem. 2) A simple calculator that takes two numbers as input and performs addition, subtraction, multiplication, or division based on user selection. 3) An adventure game that randomly selects a danger tunnel, prompts the user to choose a tunnel, and provides feedback on whether they entered the safe or danger tunnel.

Uploaded by

Max Stober
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
245 views

Programming HW

The document contains code for three different Python programs: 1) A word game that takes user input for adjectives and nouns and prints them in a poem. 2) A simple calculator that takes two numbers as input and performs addition, subtraction, multiplication, or division based on user selection. 3) An adventure game that randomly selects a danger tunnel, prompts the user to choose a tunnel, and provides feedback on whether they entered the safe or danger tunnel.

Uploaded by

Max Stober
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#Wacky Word Game program

#Part 1: Request the input words.


first_name = input("Type your name, and select enter: ")
print("")
print("Hello " + first_name + ". Let's play a game.")
print("")
adjective1 = input("Tell me an adjective, and select enter. ")
noun1 = input("Tell me a noun (plural), and select enter. ")
noun2 = input("Tell me another noun (plural), and select enter. ")
adjective2 = input("Tell me another adjective, and select enter. ")
#Part 2: Print the poem.
print(first_name + "'s Wacky Word Game")
print("")
print("Roses are " + adjective1)
print(noun1 + " are blue")
print(noun2 + " are " + adjective2)
print("And so are you!")

#Simple Calculator
num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
choice = input("Do you want to add, subtract, multiply, or divide? ")
if choice.upper() == "ADD":
answer = num1 + num2
print(num1, "+", num2, "=", answer)
elif choice.upper() == "SUBTRACT":
answer = num1 - num2
print(num1, "-", num2, "=", answer)
elif choice.upper() == "MULTIPLY":
answer = num1 * num2
print(num1, "*", num2, "=", answer)
elif choice.upper() == "DIVIDE":
answer = num1 / num2
print(num1, "/", num2, "=", answer)
else:
print("Invalid input. Sorry!")

# Adventure Game Max Stober


print ("You are lost underground in a maze of tunnels.")
import random
dangerTunnel = random.randint(1,2)
print ("Dragon in tunnel ", dangerTunnel)
tunnelChoice = 0
while tunnelChoice < 1 or tunnelChoice > 2:
tunnelChoice = int(input("Choose tunnel 1 or 2: "))
print ("")
print ("You chose tunnel ", tunnelChoice)
if tunnelChoice == dangerTunnel:
print ("You entered a tunnel with a dragon. Watch out.")
else:
print ("You entered an empty tunnel. You are safe for now.")
#print (“Dragon in tunnel “, dangerTunnel)
#answers to question 7a-c
#a-yes
#b - yes
#c - it errors

You might also like