Question: - Print hello in a while loop. - Ask user if they want to quit ( handle both upper - case and lower - case

- Print hello in a while loop.
- Ask user if they want to quit (handle both upper-case and lower-case Y/N y/n).
- Print Goodbye at end of program.
Starter Code:
while True
print("Hello!")
quit = input("Want to quit? Enter Y or N: ")
if quit =="Y"
break
print('Goodbye!')
Problem #2 Requirements:
- Simulate rolling a 6-sided die. Print number that was rolled (1,2,3,4,5, or 6)
- Do this in a loop.
- Ask user if want to roll again (Y or N). Handle both upper case / lower case.
- Print Goodbye at end of program.
Starter Code:
roll = random.randint(0,6
while True
print("You rolled ...", roll)
roll_again = input("Want to roll again? ")
if roll_again =="Y
break
print(Goodbye!)
Problem #3 Requirements:
- Simulate rolling a 6-sided die. This time do not ask the user if they want to roll
again. Instead, simply roll the die 600 times. This is best done by using a for
loop with the range function to loop 600 times. Do not print the result of each
roll. Instead, keep a count of how many times each side was rolled.
- After looping 600 times, print how many times each side was rolled, along with
a percentage. See sample output below.
-(Rolling 600 is a good number because we can expect each side to be rolled
somewhere close to 100 times)
- Print Goodbye at end of program.
- See sample output below.
< No starter code given. Write this from scratch>
Sample output:
Num of times 1 was rolled 92
Percentage is 0.15333333333333332
Num of times 2 was rolled 94
Percentage is 0.15666666666666668
Num of times 3 was rolled 115
Percentage is 0.19166666666666668
Num of times 4 was rolled 99
Percentage is 0.165
Num of times 5 was rolled 101
Percentage is 0.16833333333333333
Num of times 6 was rolled 99
Percentage is 0.165

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 Programming Questions!