Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python -- Modify the solution to Practice Problem 9.3 so that the times are d

ID: 3768941 • Letter: I

Question

In Python -- Modify the solution to Practice Problem 9.3 so that the times are displayed in a separate pop up window.

def greenwich():

     'prints Greenwich day and time info'

     time = strftime('Day: %d %b %Y Time: %H:%M:%S %p ', gmtime())

     print('Greenwich time ' + time)

def local():

      'prints local day and time info'

      time = strftime('Day: %d %b %Y Time: %H:%M:%S %p ', localtime())

      print('Local time ' + time)

# Local time button

      buttonl = Button(root, text='Local time', command=local)

      buttonl.pack(side=LEFT)

# Greenwich mean time button

      buttong = Button(root,text='Greenwich time', command=greenwich)

      buttong.pack(side=RIGHT)

Explanation / Answer

Sample code:

Sample output:

Code to copy:

#!/usr/bin/python

#import time package

import time

import tkinter

# import message box

import tkinter.messagebox

#code to dispaly greenwich mean time in pop up window

tkinter.messagebox.showinfo("Greenwich time",time.strftime('Day: %d %b %Y Time: %H:%M:%S %p ',time.gmtime()))

#code to dispaly local time in pop up window                    

tkinter.messagebox.showinfo("Local time",time.strftime('Day: %d %b %Y Time: %H:%M:%S %p ',time.localtime()))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote