Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume the days of the week are numbered 0,1,2,3,4,5,6 from Sunday to Saturday. Write a Python program with a function called getDayName() which if it

Assume the days of the week are numbered 0,1,2,3,4,5,6 from Sunday to Saturday. Write a Python program with a function called getDayName() which if it is given the day number, and it returns the day name (a string). The value for dayNumber is set in line #21 and this value should be read from the keyboard to make your program more general. Meaning that you can test different values for dayNumber without changing your code all the time. The function getDayName() is called in line #22 and it should return the string Tuesday for the value of 2 for dayNumber as set in line #21. Hint: You should use nested-if-else in your getDayName() function. Or a switch statement. You should print the value of dayName in line #23 and make sure each value of dayNumber from 0 to to 6 passed to the function getDayName(), it does return the correct string for the day name. Now, if you pass an invalid value for the dayNumber such as 10 to the getDayName() function, your getDayName() function will return an incorrect value. Hence, add a statement in your main function to validate the input such that the function getDayName() will only be called if the values for dayNumber are from 0 to 6. These are the valid values. Otherwise, display an error message and do NOT call the getDayName() function.

3 Hence, if the value for dayNumber is 10, then you should have this error message output and the getDayName() function is NOT called. Lastly, add a function called printInfo() that will accept the dayNumber and dayName value and print these two values with some text to make the output meaninful.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

Finding and scheduling appointments with new prospective clients.

Answered: 1 week ago