Hello. No matter how hard I try, I cannot seem to be able to simplify this expression : w = 1461*(x +(y-1)//12-1+((y-1)%12 + 10)//12)//4 + 365*((x + (y-1)//12-1+((y-1)%12 + 10)//12)-4*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4) + z + math.ceil((306*((y-1)%12 - 2 + 12*(1-((y-1)%12 + 10)//12))-5)/10) - 719484 Here is the full exercise to make you understand better :  One of the interesting calculations on calendar dates is to calculate for a certain date how many days have passed since another date. To simplify, we can set a reference date, such as January 1, 1970, and calculate, for a certain date, how many days have passed since the reference date. For example, on September 18, 2018 it will have been 17792 days since January 1, 1970. The following Python program allows you to do the calculation for dates between the year 1900 and the year 2100. You just have to link the variables x, y and z to the integers corresponding to the year, the month (1 to 12) and the day of the date. After the calculation, the variable w will contain the number of days elapsed since January 1, 1970. x = 2021 y = 9 z = 20 w = 1461*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4 + 365*((x + (y-1)//12-1+((y-1)%12 + 10)//12)-4*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4) + z + math. ceil((306*((y-1)%12 - 2 + 12*(1-((y-1)%12 + 10)//12))-5)/10) - 719484 print(w, "days have passed since January 1, 1970") Note that the formula to calculate the number of days is not easy to read and understand. It is very long, contains repeated parts and insignificant identifiers. An important aspect of this exercise is to make the calculation easier to read and understand. You must modify the program to eliminate redundant calculations and make it easier to understand. Your program should display the number of days from January 1, 1970 to September 20, 2021 (the date of the assignment). The program must contain only variable declarations and no loops or function declarations (which we will see later). Your program should take advantage of variable statements to avoid redundant and repetitive calculations and to make it easy to change the date. Choose meaningful variable identifiers. Your lines should not be too long, and in no case longer than 79 characters, which is a standard in programming. The point is to basically write a much clearer code, easier to read and understand with that one expression in the middle, redefining existing variables and creating new ones. PYTHON

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Hello. No matter how hard I try, I cannot seem to be able to simplify this expression : w = 1461*(x +(y-1)//12-1+((y-1)%12 + 10)//12)//4 + 365*((x + (y-1)//12-1+((y-1)%12 + 10)//12)-4*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4) + z + math.ceil((306*((y-1)%12 - 2 + 12*(1-((y-1)%12 + 10)//12))-5)/10) - 719484

Here is the full exercise to make you understand better : 

One of the interesting calculations on calendar dates is to calculate for a certain date how many days have passed since another date. To simplify, we can set a reference date, such as January 1, 1970, and calculate, for a certain date, how many days have passed since the reference date. For example, on September 18, 2018 it will have been 17792 days since January 1, 1970.

The following Python program allows you to do the calculation for dates between the year 1900 and the year 2100. You just have to link the variables x, y and z to the integers corresponding to the year, the month (1 to 12) and the day of the date. After the calculation, the variable w will contain the number of days elapsed since January 1, 1970.

x = 2021
y = 9
z = 20

w = 1461*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4 + 365*((x + (y-1)//12-1+((y-1)%12 + 10)//12)-4*(x + (y-1)//12-1+((y-1)%12 + 10)//12)//4) + z + math. ceil((306*((y-1)%12 - 2 + 12*(1-((y-1)%12 + 10)//12))-5)/10) - 719484

print(w, "days have passed since January 1, 1970")
Note that the formula to calculate the number of days is not easy to read and understand. It is very long, contains repeated parts and insignificant identifiers. An important aspect of this exercise is to make the calculation easier to read and understand.

You must modify the program to eliminate redundant calculations and make it easier to understand. Your program should display the number of days from January 1, 1970 to September 20, 2021 (the date of the assignment).

The program must contain only variable declarations and no loops or function declarations (which we will see later).

Your program should take advantage of variable statements to avoid redundant and repetitive calculations and to make it easy to change the date.

Choose meaningful variable identifiers. Your lines should not be too long, and in no case longer than 79 characters, which is a standard in programming.

The point is to basically write a much clearer code, easier to read and understand with that one expression in the middle, redefining existing variables and creating new ones. PYTHON

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education