Computer Science, asked by bhaktipatel2999, 9 months ago

Write a program in python that ask the the day number in a year in the range 2 to 365 and ask the first day of the year. Then the program should display the day on the day-number that has beeen input

Answers

Answered by savinay4090
0

Answer:

rsrddfhhvhgjhkjjjbjbhvhfvkh,ychykfvctghhthygu

Explanation:

Answered by pranavikolluru2003
2

Answer:

a=input("Enter the first day of the year:")

b=int(input("Enter a number between 2 to 365."))

c=int(input('''enter a multiple of 7 which is smaller and the closest it;

if it is a single digit number please enter 0;

if it is a number divisible by 7, enter its previous multiple'''))

if (a=="Sunday"):

   l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

   print(j)

elif (a=="Monday"):

   l=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

   print(j)

elif (a=="Tuesday"):

   l=['Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday','Monday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

   print(j)

elif (a=="Wednesday"):

   l=['Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

   print(j)

elif (a=="Thursday"):

    l=['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']

    for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

    print(j)

elif (a=="Friday"):

   l=['Friday','Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

    print(j)

else:

   l=['Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday']

   for i in range (0,b):

       if i>=c and i<=c+6:  

           j=l[i-c]

    print(j)

   

Explanation:

In the code above, for i in range (0,b):

      if i>=c and i<=c+6:  

          j=l[i-c]

  print(j)

this is the main part. So the basic idea is to split 0-365 into parts like 0-6;7-13; 14-20 and so on. Substitute these values in c and you'll understand the rest!

I know this might seem very long, but if you understand the main logic it's a very easy code.

Similar questions