Answer to Question #235055 in Python for Jowana

Question #235055
Write a function solution given a strong D representing the day of the week and an integer N that returns the day of the week N days later. The program should check of the days of the week entered os a string and its in the list.In addition the program should only accept between 0-100 and must be an integer. It will display an invalid input message. Out puts should be written in a txt.file format
1
Expert's answer
2021-09-09T05:35:13-0400
D = {0:"Saturday",1:"Sunday",2:"Monday",3:"Tuesday",4:"Wednesday",5:"Thursday",6:"Friday"}
N = int(input("Enter today's day number : "))
W = int(input("Enter the number of days after today between 0-100 days : "))
if W>=0 and W<=100:
    if N<=6 and N>0:
       print("Today is",D[N],"and the day after" ,W ,"days is",D[N])
    elif N>6:
       print("invalid input! Number is not in the list")
else:
    print("Invalid input! Number should be between 0-100")
file1 = open("myfile.txt","a")
file1.write("Today \n")
file1.close()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS