I have a past question I need help with...its a python code...I don't know how to write the code in the correct manner that it will run

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I have a past question I need help with...its a python code...I don't know how to write the code in the correct manner that it will run 

MACHINE PROJECT 1
As the documentary, "I Am Legend," reveals, there is a particular subspecies of
zombies that will only come out at night. (there is a debate as to whether that
particular species of undead are zombies or vampires, but at this critical point in
history, such debate is pedantic and counterproductive). Therefore, it is of the utmost
importance that we be able to calculate the time of the local sunrise and sunset.
Fortunately, astronomers have left us the equations that allow us to calculate this.
Unfortunately, these astronomers were eaten by zombies before they could turn the
math into a useful program. The following is the algorithm that is their legacy.
To calculate the local time of sunrise and sunset, we need the following input data:
Latitude: Latitude of the current location in degrees (+ = North, - = South)
Longitude: Longitude of the current location in degrees (+ = East, - = West)
Time zone: The local timezone as offset from UTC (e.g. CST=-6)
day of year: The numerical day of the year for which we are performing the
calculation
%3D
%3D
%3D
The following are the equations required to calculate sunrise and sunset times.
is the day of the year converted into an angle in radians.
(day.of_year – 1)
365
eqtime is the equation of time in minutes (the number of minutes that the position of
the sun differs from the actual time).
eqtime = 229.18(0.000075 + 0.001868cos(y) – 0.032077sin(y) – 0.014615cos(2y)
0.040849sin(2y))
%3D
decl is the declination of the sun in radians.
decl = 0.006918 – 0.399912cos(v) + 0.070257sin(y)
0.006758cos(2) + 0.000907sin(2y) – 0.002697cos(3y) + 0.00148sin(3y)
-
ha is the hour angle of the sun in degrees.
cos(1.5853)
cos(latitude · 50) cos(decl)
180
- tan(latitude ·
) tan(decl)
180
ha = arccOS
sunrise is the time in local minutes of sunrise.
Transcribed Image Text:MACHINE PROJECT 1 As the documentary, "I Am Legend," reveals, there is a particular subspecies of zombies that will only come out at night. (there is a debate as to whether that particular species of undead are zombies or vampires, but at this critical point in history, such debate is pedantic and counterproductive). Therefore, it is of the utmost importance that we be able to calculate the time of the local sunrise and sunset. Fortunately, astronomers have left us the equations that allow us to calculate this. Unfortunately, these astronomers were eaten by zombies before they could turn the math into a useful program. The following is the algorithm that is their legacy. To calculate the local time of sunrise and sunset, we need the following input data: Latitude: Latitude of the current location in degrees (+ = North, - = South) Longitude: Longitude of the current location in degrees (+ = East, - = West) Time zone: The local timezone as offset from UTC (e.g. CST=-6) day of year: The numerical day of the year for which we are performing the calculation %3D %3D %3D The following are the equations required to calculate sunrise and sunset times. is the day of the year converted into an angle in radians. (day.of_year – 1) 365 eqtime is the equation of time in minutes (the number of minutes that the position of the sun differs from the actual time). eqtime = 229.18(0.000075 + 0.001868cos(y) – 0.032077sin(y) – 0.014615cos(2y) 0.040849sin(2y)) %3D decl is the declination of the sun in radians. decl = 0.006918 – 0.399912cos(v) + 0.070257sin(y) 0.006758cos(2) + 0.000907sin(2y) – 0.002697cos(3y) + 0.00148sin(3y) - ha is the hour angle of the sun in degrees. cos(1.5853) cos(latitude · 50) cos(decl) 180 - tan(latitude · ) tan(decl) 180 ha = arccOS sunrise is the time in local minutes of sunrise.
sunrise = 720 + 4(longitude – ha) – eqtime – 60 · timezone
sunset is the time in UTC minutes of sunset.
sunset = 720 + 4(longitude + ha) – eqtime – 60 · timezone
To convert a time in local minutes to local time you can use the following equations
(the sunset equations look the same).
sunrise
sunrise hour
60
sunrise_minute
sunrise – (sunrise_hour · 60)
Note: The strange brackets around sunrise_hour are the floor function, which rounds
the expression inside them down. You can easily achieve this in python by simply
assigning the value to an integer variable, or you can use the floor function defined in
math module.
(Case Study Credit/Source: Machine Projects Series, Dr. Don Roberts, Evansville
University, USA)
Write a single function to implement the algorithm in the case study above. Give the
following properties to your function.
i.
ii.
а.
Use parameters
Call the function using arguments supplied by the user '
Sample Runs (to see if your code is working correctly)
Daylight-Sensitive Zombie Protection System
This program will calculate sunrise and sunset time for any date and location
Enter latitude, longitude:40.75 -74 Enter Timezone:-5
Enter day of year:180 Sunrise: 4:34
Sunset: 19:39
Daylight-Sensitive Zombie Protection System
This
program will calculate sunrise and sunset time for any date and location
Enter latitude, longitude:37.5 -88.0 Enter Timezone:-6
2
Transcribed Image Text:sunrise = 720 + 4(longitude – ha) – eqtime – 60 · timezone sunset is the time in UTC minutes of sunset. sunset = 720 + 4(longitude + ha) – eqtime – 60 · timezone To convert a time in local minutes to local time you can use the following equations (the sunset equations look the same). sunrise sunrise hour 60 sunrise_minute sunrise – (sunrise_hour · 60) Note: The strange brackets around sunrise_hour are the floor function, which rounds the expression inside them down. You can easily achieve this in python by simply assigning the value to an integer variable, or you can use the floor function defined in math module. (Case Study Credit/Source: Machine Projects Series, Dr. Don Roberts, Evansville University, USA) Write a single function to implement the algorithm in the case study above. Give the following properties to your function. i. ii. а. Use parameters Call the function using arguments supplied by the user ' Sample Runs (to see if your code is working correctly) Daylight-Sensitive Zombie Protection System This program will calculate sunrise and sunset time for any date and location Enter latitude, longitude:40.75 -74 Enter Timezone:-5 Enter day of year:180 Sunrise: 4:34 Sunset: 19:39 Daylight-Sensitive Zombie Protection System This program will calculate sunrise and sunset time for any date and location Enter latitude, longitude:37.5 -88.0 Enter Timezone:-6 2
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY