Question

In: Computer Science

Determine where the short hand and long hands meet on the clock. Involve minute and second...

Determine where the short hand and long hands meet on the clock. Involve minute and second in the expression (no longer fraction such as 5.45 but 5 minutes 60x0.45=27 seconds). Run full 12 hours for AM or PM. Use python to solve this problem. Use numpy if needed.

Solutions

Expert Solution

CODE:

#minuteHandAngle is the angle that the long hand sweeps at any given second
#hourHandAngle is the angle that the short hand sweeps at any given second
minuteHandAngle = 0
hourHandAngle = 0
#this list stores the times where the short hand and the long hand meet
meetAt = []
#runnning a loop for 12 hours or 43200 seconds where i denotes each second
for i in range(12*60*60 + 1):
#the minute or long hand sweeps 1 degree every 10 seconds therefore 360 degrees in 3600 seconds
if(i%10 == 0):
minuteHandAngle += 1
#after every hour the minute hand starts from the beggining
if(minuteHandAngle%360 == 0):
minuteHandAngle = 0
#the hour hand sweeps 360 degrees in 12 hours or 12*60*60 seconds or 43200 seconds
#so hour hand sweeps 1 degree after every 120 seconds
if(i%120 == 0):
hourHandAngle += 1
#if at any time the hour hand and the minute hand are at the same angle
#they are at same position
if(hourHandAngle == minuteHandAngle):
meetingTime = str(int(i/3600))+":"+str(int(i/60)-int(i/3600)*60)
if(meetingTime not in meetAt):
#displaying the times the short hand and long hand meet
print("Both hands meet at: {}:{} A.M.".format(str(int(i/3600)),str(int(i/60)-int(i/3600)*60)))
meetAt.append(meetingTime)

__________________________________________

CODE IMAGES AND OUTPUT:

______________________________________________

Feel free to ask any questions in the comments section

Thank You!


Related Solutions

Given a clock on the planet 9 with hour, minute, and second hands, where day last 14 hours (hour hand circles twice for a day)
USE MATLABGiven a clock on the planet 9 with hour, minute, and second hands, where day last 14 hours (hour hand circles twice for a day)a) At what time (in hours), the first time after 0th hour, all 3 hands will overlap,b) At what times (in hours) they will overlap between 0th hour and 7th hour?
At 3:00 the hour hand and the minute hand of a clock point in directions that...
At 3:00 the hour hand and the minute hand of a clock point in directions that are 90° apart. What is the first time after 3:00 that the angle between the two hands has decreased to 26.0°?
A clock has an hour hand of length 2.4 cm and a minute hand of length...
A clock has an hour hand of length 2.4 cm and a minute hand of length 3.8 cm. (a) Calculate the position and velocity of the hour hand at noon. (b) Calculate the position and velocity of the minute hand at 12:15.
First, determine if there is sufficient capacity to meet the special order Second, determine which currently-sold...
First, determine if there is sufficient capacity to meet the special order Second, determine which currently-sold product is less profitable (UCM per scarce resource). If you have to give up some of your regular customers, give up those who are least profitable. Then can you start the four-step method. Note: On the old test twos on iLearn, you will see examples of similar problems with answers. The student group, ALPFA, is taking advance orders to sell bean pupusas and pork...
What is the impact of using long term liabilities to meet short term needs?
What is the impact of using long term liabilities to meet short term needs?
The economy is initially at point A; where the economy is in both short and long...
The economy is initially at point A; where the economy is in both short and long run equilibrium (2.5 marks). Then, the government increases its spending and the short run equilibrium is at point B (2.5 marks), and later the factor market reacts by rising wages and other factor prices and the economy reaches back to its potential GDP position at Point C (2.5 marks). Then the price of oil skyrocketed and it pushes the economy into a recession and...
As a beginner investor. Where should they begin? Should the focus be on short or long...
As a beginner investor. Where should they begin? Should the focus be on short or long term trends?
Hardy-Weinberg Equilibrium Problems: A population of beetles have either long or short antennae, where short antennae...
Hardy-Weinberg Equilibrium Problems: A population of beetles have either long or short antennae, where short antennae are dominant over long antennae. There are 653 individuals in the population. 104 beetles have long antennae and 549 have short antennae. a. Determine the frequency of the dominant and recessive alleles and the frequency of individuals with dominant, heterozygous, and recessive genotypes. The next generation of beetles in this population has 560 individuals with short antennae and 840 individuals with long antennae. b....
Determine the targeted financial goals for short term, intermediate and long term. (800 words)
Determine the targeted financial goals for short term, intermediate and long term. (800 words)
Read the following news items and explain where a short-run decision and a long-run decision are...
Read the following news items and explain where a short-run decision and a long-run decision are involved? a. January 31, 2020: Tim Horton will open 60 more stores in Asian countries   b. March 30, 2020: All stores of Tim Horton will shut down on Tuesday stores so that baristas can receive a refresher course. c. June 2, 2020: Tim Horton replaces baristas with vending machines. d. June 30, 2020: Tim Horton is closing 200 stores in British Columbia by the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT