For python please Write a function that takes in a day of th

For python please.

Write a function that takes in a day of the week (e..g, x) and a number of days (e.g., y), and returns the day of the week it will be in y days from x. You should not use a loop.

Solution

def dayOfWeek(day,noOfDays):

num=0

if day==\'sunday\':

num=1

elif day==\'monday\':

num=2

elif day==\'tuesday\':

num=3
elif day==\'wednesday\':
num=4
elif day==\'thursday\':
num=5
elif day==\'friday\':
num=6
elif day==\'satrday\':
num=7
else:
print \' invalid day\'
next=num+noOfDays
if next>7:
next=next%7
if next==0:
return \'Sunday\'
if next==1:
return \'Monday\'
if next==2:
return \'Tuesday\'
if next==3:
return \'Wednesday\'
if next==4:
return \'Thursday\'
if next==5:
return \'Friday\'
if next==6:
return \'Satrday\'

For python please. Write a function that takes in a day of the week (e..g, x) and a number of days (e.g., y), and returns the day of the week it will be in y da

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site