Questionn 1. Write a Python program that uses boolean logic to determine if a user is eligible to vote. The criteria for eligibility is that the user must be a citizen and must be 18 or older. Include comments in your code to explain each part of the program.
# Get user's age and citizenship status as input
age = int(input("Enter your age: "))
is_citizen = input("Are you a citizen? (yes/no): ").lower()
# Check if the user is both a citizen and 18 or older
is_eligible = is_citizen == "yes" and age >= 18
# Check the eligibility and provide a response
if is_eligible:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
You are eligible to vote.
Question 2 A company decided to give bonus of 5% to employee if his/her year of service is more than 5 years. Ask user for their salary and year of service and print the net bonus amount.
years = int(input("How many years hae you worked at our company"))
salary = float(input('What is your salary'))
bonus_percent = 5
if years > 5:
bonus_amt = (bonus_percent/100) * salary
print(f"You are eligible for a {bonus_percent}% bonus of ${bonus_amt:.2f}.")
else:
print('youre not eligable for a bonus')
if years > 5:
net_bonus_amount = bonus_amt
else:
net_bonus_amount = 0
print(f"Net bonus amount: ${net_bonus_amount:.2f}")
You are eligible for a 5% bonus of $3400.00.
Net bonus amount: $3400.00
Question 3. A school has following rules for grading system: a. Below 25 - F b. 25 to 45 - E c. 45 to 50 - D d. 50 to 60 - C e. 60 to 80 - B f. Above 80 - A Ask user to enter marks and print the corresponding grade.
# Get user input for marks
marks = float(input("Enter your marks: "))
# Define the grading system 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 corresponding grade
print(f"Your grade is: {grade}")
Your grade is: C