Question

1. Day of the Week Write a program that asks the user for a number in...

1. Day of the Week

Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The program should display an error message if the user enters a number that is outside the range of 1 through 7.

(On PYTHON IDLE 3.7.2)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
lst = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
n = eval(input("Enter number: "))
try:
    if(n < 1 or n >7):
        raise IndexError("Exception: Please enter a number between 1 to 7")
    result = lst[n-1]
except IndexError as ie:
    print(ie)
else:
    print(result)

Enter number: 1
Monday

Add a comment
Know the answer?
Add Answer to:
1. Day of the Week Write a program that asks the user for a number in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to write a program in java using two array lists. I need to program...

    I need to write a program in java using two array lists. I need to program to prompt the user to enter a day of the week and return an output of a predetermined temperature for the day they selected. I also need the program the output the average of daily temperatures across the week if the user inputs "week". So basically if i set the temperatures to something arbitrary i.e.: Monday = 50 Tuesday = 55 Wednesday = 52...

  • OE5 QUESTION 2 Given: U = {x | x is a day of the week) A...

    OE5 QUESTION 2 Given: U = {x | x is a day of the week) A = {x|x is a weekday} B = {x|x is a day of the week that starts with the letter "T"} C = {Wednesday, Monday, Thursday, Sunday} D = {Friday, Wednesday} E = {Tuesday, Saturday, Sunday} P(EU (C'-D)) = OA {@, (Tuesday) {Saturday}, {Tuesday, Saturday}} B.4 0.8 D., {Tuesday}, {Saturday}, {Sunday}, {Tuesday, Saturday}, Tuesday, Sunday}, {Saturday, Sunday}, {Tuesday, Saturday, Sunday} E{@, (Tuesday}, {Saturday}, {Sunday}, {Tuesday,...

  • Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock....

    Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...

  • Write a C++ program using four enumerators. Initialize each as follows: 1. first, second, third, fourth,...

    Write a C++ program using four enumerators. Initialize each as follows: 1. first, second, third, fourth, fifth, sixth, seventh, eighth, ninth 2. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday 3. curve, fast, knuckle, slider 4. single, double, triple, homer The program should prompt a user to input a character array or 4 numbers pertaining to each enumerator. Display help text to assists the user. The help text should display the smallest and largest possible valuesfor each inputted number. Validate the...

  • Assuming today is Friday, what day of the week will it be in 91 days from...

    Assuming today is Friday, what day of the week will it be in 91 days from today? Sunday O Monday Tuesday Wednesday ? Thursday O Friday O Saturday

  • USING PYTHON. (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller...

    USING PYTHON. (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7 where - h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). - q is the day of the month. - m is the month (3: March, 4: April, ...,...

  • Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Bl...

    Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Blinky Pinky and Clyde will get to play pinball in that month. The function provided will increment the day of the week to the next correct day. Function written in 3a): def pinball(dayOfWeek, dayOfMonth) : if dayOfMonth % 4 ==0: return "Pinky"...

  • WATU WA Fal Exam QUESTION 8 Given: U = {x | x is a day of...

    WATU WA Fal Exam QUESTION 8 Given: U = {x | x is a day of the week) A = {x | x is a weekday} B = {x | x is a day of the week that starts with the letter "T"} C = {Wednesday, Monday, Thursday, Sunday} D = {Friday, Wednesday} E = {Tuesday, Saturday, Sunday} P(EU (C'-D)) = A {@, (Tuesday), (Saturday), (Sunday}, {Tuesday, Saturday). {Tuesday, Sunday}, {Saturday, Sunday), {Tuesday, Saturday, Sunday}} B{, (Tuesday), (Saturday}, {Tuesday, Saturday}}...

  • QUESTION 5 Given: U = {x | x is a day of the week} A =...

    QUESTION 5 Given: U = {x | x is a day of the week} A = {x | x is a weekday} B = {x|x is a day of the week that starts with the letter "T"} C = {Wednesday, Monday, Thursday, Sunday} D = {Friday, Wednesday} E = {Tuesday, Saturday, Sunday} \(D U E') n (B-C)' = A7 B.2 0.3 0.4 E5

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT