Use the function design recipe to develop a function named alarm_clock. The function has two parameters. The first parameter is named day and encodes the day of the week: 0=Sun, 1=Mon, 2=Tue, ..., 6-Sat. The second parameter is named vacation, and is True if we are on vacation. The function returns a string of the form "hour:00" that indicates when the alarm will ring. On weekdays, the string should be "7:00", but on the weekend, the string should be "10:00". If we are on vacation, then on weekdays the string should be "10:00", but on the weekend the string should be "off".

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.4: A Case Study: Constructing A Date Class
Problem 7E
icon
Related questions
Question

Please complete the exercise following the instructions. Thank you!

Use the function design recipe to develop a function named alarm_clock. The function has
two parameters. The first parameter is named day and encodes the day of the week: 0=Sun,
1-Mon, 2=Tue, 6-Sat. The second parameter is named vacation, and is True if we are on
vacation. The function returns a string of the form "hour:00" that indicates when the alarm will
ring. On weekdays, the string should be "7:00", but on the weekend, the string should be
"10:00". If we are on vacation, then on weekdays the string should be "10:00", but on the
weekend the string should be "off".
2
You are permitted to use local variables, although they aren't necessary. A function that uses
Boolean operators will be shorter than one that does not.
Your function definition must have type annotations and a complete docstring. Use the Python
shell to test alarm_clock.
Transcribed Image Text:Use the function design recipe to develop a function named alarm_clock. The function has two parameters. The first parameter is named day and encodes the day of the week: 0=Sun, 1-Mon, 2=Tue, 6-Sat. The second parameter is named vacation, and is True if we are on vacation. The function returns a string of the form "hour:00" that indicates when the alarm will ring. On weekdays, the string should be "7:00", but on the weekend, the string should be "10:00". If we are on vacation, then on weekdays the string should be "10:00", but on the weekend the string should be "off". 2 You are permitted to use local variables, although they aren't necessary. A function that uses Boolean operators will be shorter than one that does not. Your function definition must have type annotations and a complete docstring. Use the Python shell to test alarm_clock.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning