0% found this document useful (0 votes)
22 views

PythonBasic Assignment15

Uploaded by

nikhilesh singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
22 views

PythonBasic Assignment15

Uploaded by

nikhilesh singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
6110123, 10220 PM In In In In In 24): 25] 26] 27) 28] Untiles - Jupyter Notebook Assignment 15 1.How many seconds are in an hour? Use the interactive interpreter as a calculator and multiply the number of seconds in a minute (60) by the number of minutes in an hour (also 60). print (62*60) 3600 2. Assign the result from the previous task (seconds in an hour) to a variable called seconds_per_hour. seconds_per_hour = 6@*69 print (seconds_per_hour) 3600 3. How many seconds do you think there are in a day? Make use of the variables seconds per hour and minutes per hour minutes_per_hour = 60 print (seconds_per_hour*24) 86400 4, Calculate seconds per day again, but this time save the result in a variable called seconds_per_day seconds_per_day = 24*60*60 print (seconds_per_day) 36400 5. Divide seconds_per_day by seconds_per_hour. Use floating-point (/) division, print(seconds_per_day/seconds_per_hour) 24.8 localhost 8888/notebooks/Documents/Untied jpynb%kernel_name=python3#Assignmont 14 42 6110123, 10220 PM In In locahos 8888/notebooks/Documents/Untied ipynb?kern 29]: 30]: Untiles - Jupyter Notebook 6. Divide seconds_per_day by seconds_per_hour, using integer (//) division. Did this number agree with the floating-point value from the previous question, aside from the final .0? print (seconds_per_day//seconds_per_hour, end="*) print(’ -> yes this values agree with the floating point value fron the previous question’ 24 ~> yes this values agree with the floating point value from the previous question 7. Write a generator, genPrimes, that returns the sequence of prime numbers on successive calls to its next() method: 2, 3, 5, 7, 11, def genPrimes(): n=@ while True: ifn =s2orna=3 yield n elif ((m-1)%6 == 0 or (m+1)%6 == 0) and n I yield n n= ned output = genPrimes() for ele in range(5): print (next (output) ) name=pytionstssignment-14 22

You might also like