problem 1
citizen = input("Are you a US citizen? (yes/no)")
#if yes, they need to be 18 or older
if citizen == "yes":
age = int(input("what is your age"))
if age >= 18:
#if they are 18 or older, they can vote
print("you are eligible to vote!")
else:
#if not, they can't vote
print("sorry, you are too young to vote. maybe wait a few years!")
else:
#if they are not a citizen, they also can't vote
print("sorry, you are not eligible to vote")
you are eligible to vote!
problem 2
salary = (input("What is your salary?"))
years = int(input("How long have you worked for?"))
# Check if the employee is eligible fo bonus
if years > 5:
bonus = 0.05 * salary
print("yay! you're eligible for a bonus of $"{bonus})
else:
print("sorry, you're not eligible for a bonus.")
Cell In[12], line 7
print("yay! you're eligible for a bonus of $"{bonus})
^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
problem 3
#user input
marks = float(input("What are your marks?"))
# all the grade rules
if marks < 25:
grade = "F"
elif 25 <= marks < 45:
grade = "E"
elif 45 <= marks < 50:
grade = "D"
elif 50 <= marks < 60:
grade = "C"
elif 60 <= marks < 80:
grade = "B"
else:
grade = "A"
# Print the grade
print("Your grade is a(n)", grade)
Your grade is a(n) A