Question: 1. Exercise 2.18 (Current time) Listing 2.7, ShowCurrentTime.py, gives a program that dispiays the current timein GMT. Revise the program so that it prompts the

1. Exercise 2.18 (Current time) Listing 2.7, ShowCurrentTime.py, gives a program that dispiays the current timein GMT. Revise the program so that it prompts the user to enter the time zone in hours away from (offset to) GMT and displays the time in the specified time zone.

Enter the time zone offset to GMT : -5

The current time is :

I need this exact code using python. If you can please write neatly or type and please put exact coding that i need to use because I am confused with this exercise.

This is the coding I have currently typed. What do I need to add to this to make python run the entire answer?

This is what I get as my output:

This Program Displays The Time In The Specified Time Zone.

Enter the time zone offset to GMT: -5

My current input:

import time

print("This Program Displays The Time In The Specified Time Zone.")

#Obtain the total milliseconds

totalMilliseconds = int(round(time.time()*1000))

#Obtain the total seconds

totalSeconds = totalMilliseconds / 1000

#Compute the current second in the minute in the hour

currentSecond = totalSeconds % 60

#Obtain the total minutes

totalMinutes = totalSeconds / 60

#Compute the current minute in the hour

currentMinute = totalMinutes % 60

#Obtain the total hours

totalHours = totalMinutes / 60

#Compute the current hour

currentHour = totalHours % 24

timeZoneOffset=int(input("Enter the time zone offset to GMT: -5 " ))

currentHour = currentHour + timeZoneOffset;

if currentHour >= 24:

currentHour = currentHour - 24

elif currentHour == 0:

currentHour = 24 + timeZoneOffset

print("Current time is " + str(round(currentHour)) + ":"

+ str(round(currentMinute)) + ":" + str(round(currentSecond)) +

" GMT " + str(round(timeZoneOffset)) + ".");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!