Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
251DProgramming and Robotics [email protected]
1. Twin Python Projects – Numbers and Words
Number Project
This code calculates your change in cash for the latest amount of bills.
def main():
price = int(input(“You enter a store with a $100 bill, how much do you spend?”))
total = price
if total > 100:
print(“too expensive, you only have a $100 bill”)
else:
print(“you bought an item for $” + str(total) + “, and paid it with a $100 bill\nyour change is:”)
price = coump20(0, 100 – price)
price = coump10(0, price)
price = coump5(0, price)
price = coump1(0, price)
def coump20(z, p):
z = p // 20
p = p – z * 20
print(str(z) + “, $20 bill(s)”)
return p
def coump10(z, p):
z = p // 10
p = p – z * 10
print(str(z) + “, $10 bill(s)”)
return p
def coump5(z, p):
z = p // 5
p = p – z * 5
print(str(z) + “, $5 bill(s)”)
return p
def coump1(z, p):
z = p // 1
p = p – z * 1
print(str(z) + “, loonie(s)”)
return p
main()
Word Project
This code tells a scary story about you, Amy, and Jonathan
def main():
print(“””Hello, this is a story game where you will chose your path though a Haunted Mansion.
CHOOSE WHISLY!!!
!!!(IF_YOUR_NAME_IS_AMY_OR_JONATHAN_CHANGE_IT)!!!”””)
name = input(“please enter you name: “)
age = int(input(“please enter your age: “))
if age <= 13:
print(“you are too young to play this story game”)
else:
friend = room1(name)
if friend != 1:
end = room2(friend,name)
if end == 2:
print(“”)
elif end != 1 and friend.lower() == “amy”:
print(“”)
print(“You keep on running until possesed jonathan tells you that this was all a prank.\nBoth of them start cracking up at the prank and you three go home.\n(GOOD_ENDING:::THANKS_FOR_PLAYING)”)
else:
print(“”)
print(“””Jonathan jumps out the window and lands to hard.
You see possesed Amy chase you, so you jump too.
Luckly jonathans body softens the landing and you run away scared and lost FOREVER.
THE END!!!(BAD_ENDING)”””)
else:
print(“”)
def room1(name):
print(“”)
print(“””you and your friends are exploring this haunted mansion on halloween night.”””)
user_input = input(“who should enter the mansion first(” + name + “, Amy, Jonathan)”)
if user_input.lower() == name.lower():
print(“”)
print(“””You enter and a ghost suddenly possesses you.
you start to feel dizzy while the ghost takes control over you body and you black out.
(GAME_OVER)”””)
return 1
elif user_input.lower() == “amy”:
print(“”)
print(“””Amy enters first, and suddenly a ghost possesses
Amy and the door shuts behind you!”””)
friend = “Jonathan”
return friend
elif user_input.lower() == “jonathan”:
print(“”)
print(“””Jonathan enters first, and suddenly a ghost possesses
Jonathan and the door shuts behind you!”””)
friend = “Amy”
return friend
else:
print(“””That is not a valid option,
please check you spelling”””)
return 1
def room2(frined, name):
print(“”)
print(“You and ” + str(frined) + ” run passed the ghost friend and runs up stairs and you find a broken window”)
user_input = input(“who jumps first(” + str(name) + “, ” + str(frined) + “)”)
if user_input.lower() == name.lower():
print(“”)
print(“You jump out the window and landed to hard.\n (GAME_OVER)”)
return 2
elif user_input.lower() == frined.lower():
return 3
else:
print(“””\nThat is not a valid option,
please check you spelling”””)
return 2
main()
2. Remembrance Day Poppy (vector demonstration)
This is the portfolio of Matilda van der Spuy
252DWeb Development [email protected]
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
251EDigital Arts [email protected]
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
251EDigital Arts [email protected]
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
251EDigital Arts [email protected]
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
251EDigital Arts [email protected]
251DProgramming and Robotics [email protected]
251DProgramming and Robotics [email protected]
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!