Pyhton Assignment # 5 – Random Numbers Thought for the day Create an application
ID: 3860441 • Letter: P
Question
Pyhton Assignment # 5 – Random Numbers
Thought for the day
Create an application that randomly prints a “thought for the day”.
Do some online research and locate seven inspirational quotes.
Here is one I found, without attribute: “The happiest people don’t have the best of everything, they just make the best of everything.”
Generate a positive integer between 1 and 7.
Use if-elif-else to select the random quote
If number == 1:
print “The happiest people don’t have the best of everything, they just make the best of everything.”
elif . . .
Explanation / Answer
import random #importing the random
number=0; #declaring variable called number
number=random.randint(1,7) #generating random number and assigning it to number
print (number) #printing number for understanding purpose
#if condtions starts
if number==1:
print ("The happiest people don’t have the best of everything, they just make the best of everything.")
elif number==2:
print ("Helping hands are better than praying lips.")
elif number==3:
print ("Time and tide waits for none.")
elif number==4:
print ("There is nothing permanent except change.")
elif number==5:
print ("Let us sacrifice our today so that our children can have a better tomorrow.")
elif number==6:
print ("It is better to be feared than loved, if you cannot be both.")
elif number==7:
print ("If you cannot do great things, do small things in a great way.")
Ouput:
Ouput-2:
7
If you cannot do great things, do small things in a great way.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.