2.3 Selection Assignment.pdf
# selection1.py
# Leen Saflo
# tell user their orientation based on compass bearings
deg = int(input("Enter your compass bearings (0-360): ")) # I'll use deg for the possible inputs
if deg == 45 or deg == 315:
orientation = "North"
elif deg == 135 or deg == 225:
orientation = "South"
elif deg > 315 or deg < 45:
orientation = "North"
elif deg >= 45 and deg < 135:
orientation = "East"
elif deg >= 135 and deg < 225:
orientation = "South"
elif deg >= 225 and deg < 315:
orientation = "West"
print("Your orientation is closest to the", orientation)
# selection2.py
# Leen Saflo
# exchange 5 currencies to CAD, displaying a menu
print("""
currencies exchange Rates
------------------------------------
1. USD 0.73749396
2. EUR 0.66817525
3. GDP 0.56421008
4. AUD 1.1066861
5. JPY 105.46014
""")
USD = 0.73749396 # using these variables to represent exchange rate
EUR = 0.66817525
GDP = 0.56421008
AUD = 1.1066861
JPY = 105.46014
currency = input ("Which currency would you like: ")
amount = float(input("How much would you like to exchange: "))
if currency == "USD":
inCAD = USD * amount # inCAD is the value in Canadian dollars
elif currency == "EUR":
inCAD = EUR * amount
elif currency == "GDP":
inCAD = GDP * amount
elif currency == "AUD":
inCAD = AUD * amount
elif currency == "JPY":
inCAD = JPY * amount
print("That'll cost you", inCAD , "in CAD.")
# selection3.py
# Leen Saflo
# tell the user the cost of their tickets depending on age group and # of tickets
age = input("Welcome to transit WIndsor, are you an adult, senior or student: ").lower()
tickets = input("How many tickets would you like (1 ticket, 10 tickets or tranzip Pass): ")
if age == "adult" and tickets == "1": # age is for age groups, tickets is # of tickets
print("That'll cost 2.35$")
elif age == "adult" and tickets == "10":
print("That'll cost 20.30$")
elif age == "adult" and tickets == "tranzip pass":
print("That'll cost 75$")
elif age == "senior" and tickets == "1":
print("That'll cost 1.60$")
elif age == "senior" and tickets == "10":
print("That'll cost 15.60$")
elif age == "senior" and tickets == "tranzip pass":
print("That'll cost 38.50$")
elif age == "student" and tickets == "1":
print("That'll cost 1.60$")
elif age == "student" and tickets == "10":
print("That'll cost 15.60$")
elif age == "student" and tickets == "tranzip pass":
print("That'll cost 52$")
# selection4.py
# Leen Saflo
# Determining user's eligibility for a credit card
age = int(input("Enter your age: "))
income = int(input("Enter your annual income: "))
sameAddress = int(input("Enter years you've lived at the same address: "))
sameJob = int(input("Enter years you've had the same job: "))
totalPoints = 0 # this represents how many points are gained/lost, starts at 0
if age <= 20:
totalPoints -= 10
elif age <= 30:
totalPoints += 20
elif age <= 50:
totalPoints += 25
if income <= 45000:
totalPoints += 12
elif income <= 70000:
totalPoints += 24
else:
totalPoints += 30
if sameAddress < 1:
totalPoints -= 5
elif sameAddress <= 3:
totalPoints += 5
elif sameAddress <= 8:
totalPoints += 12
else:
totalPoints += 20
if sameJob < 2:
totalPoints -= 4
elif sameJob <= 4:
totalPoints += 8
else:
totalPoints += 15
if totalPoints <= 20:
print("You do not qualify for a card.")
elif totalPoints <= 35:
print("You qualify for a $500 limit card.")
elif totalPoints <= 60:
print("You qualify for a $5000 limit card.")
else:
print("You qualify for a $10,000 limit card.")
# selection5.py
# Leen Saflo
# Harry Potter trivia with score
print("Welcome to Harry Potter trivia!")
score = 0 # score will keep count, starts at 0
# all variables that start with q represent questions
q1 = input("What house is Harry Potter in: ").lower()
if q1 == "gryffindor":
print("Yes! Well done.")
score += 1
else:
print("Wrong! have you even read the books? The answer was gryffindor.")
q2 = input("What is the name of Harry Potter's pet owl: ").lower()
if q2 == "hedwig":
print("Correct, may he rest in peace.")
score += 1
else:
print("Nope! The answer was Hedwig.")
q3 = input("Who is the headmaster of Hogwarts for most of the series: ").lower()
if q3 == "dumbledore":
print("That's right! We don't talk about his awful replacement.")
score += 1
else:
print("That's wrong, Dumbledore was the headmaster.")
q4 = input("What is the name of the sport played on broomsticks in the wizarding world: ").lower()
if q4 == "quidditch":
print("Correct.")
score += 1
else:
print("Wrong, the answer was Quidditch.")
q5 = input("Who is Harry's best friend with red hair: ").lower()
if q5 == "ron weasley":
print("Yes, Ron Weasley.")
score += 1
else:
print("No, his name was Ron Weasley.")
q6 = input("Who is the dark wizard Harry must defeat: ").lower()
if q6 == "voldemort":
score += 1
print("Yes, He Who Must Not Be Named.")
else:
print("The answer was Voldemort.")
q7 = input("What is Harry's mom's name: ").lower()
if q7 == "lily potter":
score += 1
print("Yes, may she rest in peace.")
else:
print("The answer was Lily Potter; maybe consider rewatching the movies.")
q8 = input("How many books are in the Harry Potter series: ").lower()
if q8 == "seven":
score += 1
else:
print("Incorrect, there are seven.")
q9 = input("What house at Hogwarts does Draco Malfoy belong to: ").lower()
if q9 == "slytherin":
score += 1
print("Yes, he was in Slytherin.")
else:
print("No, he was in Slytherin.")
q10 = input("What spell is used to make things levitate: ").lower()
if q10 == "wingardium leviosa":
score += 1
print("Yeppp, you know your stuff.")
else:
print("Hermione would roll her eyes, it's Wingardium Leviosa.")
percent = score * 10 # How the percent is found
print(f"Your score is {percent}%.")