# Homework 1
# Function to check if you are eligible to vote.
def votecheck(age):
if age >= 18:
# If you are older than 18, then you are eligible to vote.
print("You are eligible to vote.")
else:
# If you are younger than 18, then you are not eligible to vote.
print("You are not eligible to vote.")
# Takes input of the user's age and converts it to an integer.
age = input("Please enter your age: ")
age = int(age)
votecheck(age)
# Homework 2
# Function to check if the person has a bonus and calculate how much of a bonus there is.
def bonuscheck(salary, years):
if years > 5:
# If the person has been at the company for more than 5 years, there is a 5% bonus.
bonus = salary * 0.05
print("Net Bonus:", bonus, "dollars")
else:
# If the person has been at the company for less than 5 years, there is no bonus.
print("Net Bonus: 0 dollars")
# Takes the input of the number of years and the salary.
years = input("How many years have you been in the company: ")
years = float(years)
salary = input("What is your annual salary: ")
salary = float(salary)
bonuscheck(salary, years)
# Homework 3
# Function to print out the grade that a person has earned.
def gradecheck(score):
# For checks if the score is an F and slowly moves up until it gets to A.
if score < 25:
print("F")
elif score >= 25 and score < 45:
print("E")
elif score >= 45 and score < 50:
print("D")
elif score >= 50 and score < 60:
print("C")
elif score >= 60 and score < 80:
print("B")
elif score >= 80:
print("A")
# Takes an input that is the person's score and runs the function gradecheck.
score = input("Please enter your score: ")
score = float(score)
gradecheck(score)
Boolean Expressions and Conditionals • 5 min read
Description
Lesson on Booleans and Conditionals