AMPS | THARC | KE8QZC | SFW | TSW
ORCID iD icon

Return to the class
Problem A: A "sleep debt" represents the difference between a person's desirable and actual amount of sleep. Write a program that prompts the user to enter how many hours they slept each day over a period of seven days. Using 8 hours per day as the desirable amount of sleep, determine their sleep debt by calculating the total hours of sleep they got over a seven-day period and subtracting that from the total hours of sleep they should have gotten. If the user does not have sleep debt, display a message expressing your jealousy.

Problem B: The len function returns the length of a string. Consider
message="abcd" print(len(message))
which will print "4". Use this function to write a program with a loop that repeatedly asks the user to enter a string. The user should enter nothing (i.e. hit "Enter" without inserting any text) to signal the end of the loop. Once the loop ends, the program should display the average length of the words entered.

Problem C: Write a program that uses nested loops to draw this pattern:
## 
# #
#  #
#   #
#    #
#     #

Problem D: Draw the following picture (or something very similar to it) using the turtle package: