CODEHS Python Chapter 4 Exam | Questions with Correct Answers|
Verified
4.1.4: Do You Have a Cat? - Answer"""
This program should declare a boolean that describes whether or
not you have a cat. Then you should print out an informative
message to the user.
"""
have_car = True
print("Do you have a cat? " + str(have_car))
4.2.6: Can You Graduate? - Answer# Enter your code here
has_enough_units = True
has_met_requirements = False
can_graduate = has_enough_units and has_met_requirements
print("Can graduate? " + str(can_graduate))
4.2.7: School's Out - Answer# Enter your code here
is_weekday = False
is_holiday = True
is_weekend = True
no_school_today = is_weekend or is_holiday
not no_school_today
print("There is school today? " + str(no_school_today))
4.3.5: Rolling Dice - Answer# Enter your code here
first_die = int(input("What did you roll on your first die? "))
print(first_die)
, second_die = int(input("What did you roll on your second die? "))
print(second_die)
rolled_doubles = first_die == second_die
print("Rolled doubles: " + str(rolled_doubles))
4.3.6: All Star - Answerpoints = int(input("How many points per game do you score? "))
rebounds = int(input("How many rebounds per game do you get? "))
assists = int(input("How many assists per game do you get? "))
all_star = points >= 25 or points >= 10 and rebounds >= 10 and assists >= 10
print("Is all star? " + str(all_star))
4.4.7: Teenagers - Answer# Enter your code here
age = int(input("What is your age? "))
teenager = age >= 13 and age <= 19
if teenager:
print("Yes, you are a teenager.")
else:
print("No, you are not a teenager.")
4.4.8: Meal Planner - Answer# Enter your code here
meal = input("What meal do you want. Breakfast, lunch, or dinner? ")
if meal == "breakfast":
print("Have some pancakes")
elif meal == "lunch":
print("Have a sandwich")
elif meal == "dinner":
print("Have a steak")
4.5.4: Growing Circle - Answer# Start coding here. Don't forget to click the canvas
Verified
4.1.4: Do You Have a Cat? - Answer"""
This program should declare a boolean that describes whether or
not you have a cat. Then you should print out an informative
message to the user.
"""
have_car = True
print("Do you have a cat? " + str(have_car))
4.2.6: Can You Graduate? - Answer# Enter your code here
has_enough_units = True
has_met_requirements = False
can_graduate = has_enough_units and has_met_requirements
print("Can graduate? " + str(can_graduate))
4.2.7: School's Out - Answer# Enter your code here
is_weekday = False
is_holiday = True
is_weekend = True
no_school_today = is_weekend or is_holiday
not no_school_today
print("There is school today? " + str(no_school_today))
4.3.5: Rolling Dice - Answer# Enter your code here
first_die = int(input("What did you roll on your first die? "))
print(first_die)
, second_die = int(input("What did you roll on your second die? "))
print(second_die)
rolled_doubles = first_die == second_die
print("Rolled doubles: " + str(rolled_doubles))
4.3.6: All Star - Answerpoints = int(input("How many points per game do you score? "))
rebounds = int(input("How many rebounds per game do you get? "))
assists = int(input("How many assists per game do you get? "))
all_star = points >= 25 or points >= 10 and rebounds >= 10 and assists >= 10
print("Is all star? " + str(all_star))
4.4.7: Teenagers - Answer# Enter your code here
age = int(input("What is your age? "))
teenager = age >= 13 and age <= 19
if teenager:
print("Yes, you are a teenager.")
else:
print("No, you are not a teenager.")
4.4.8: Meal Planner - Answer# Enter your code here
meal = input("What meal do you want. Breakfast, lunch, or dinner? ")
if meal == "breakfast":
print("Have some pancakes")
elif meal == "lunch":
print("Have a sandwich")
elif meal == "dinner":
print("Have a steak")
4.5.4: Growing Circle - Answer# Start coding here. Don't forget to click the canvas