Question: Python Programming In this problem, you will be writing a program from scratch that simulates throwing a special die with faces numbered 1 through 2

Python Programming In this problem, you will be writing a program from scratch that simulates throwing a special die with faces numbered 1 through 20. Along with a number, each face also has a special symbol or effect associated with it:
If the number on the die is 20, it's considered a "CRITICAL HIT!"
Otherwise, each number is associated with a symbol as follows:
o If the number divides by 4 exactly, the symbol is a Sword.
o If the number divided by 4 has a remainder of 1, the symbol is a Shield.
o If the number divided by 4 has a remainder of 2, the symbol is a Spell.
o If the number divided by 4 has a remainder of 3, the symbol is a Potion.
At the start of the program, the user will be asked how many times they wish to roll the die. They must enter a number between 5 and 15. The program will then simulate rolling the die that number of times.
Sample Output:
How many times do you want to roll the die? 3
Enter a number between 5 and 15.
How many times do you want to roll the die? 7
Roll 1: 8==> Sword
Roll 2: 13==> Shield
Roll 3: 17==> Spell
Roll 4: 20==> CRITICAL HIT!
Roll 5: 3==> Spell
Roll 6: 5==> Shield
Roll 7: 10==> Spell
Thanks for playing!
The program should consist of TWO functions:
main This function will be the main routine, and it should do the following:
Prompt the user to enter the number of times they want to roll the die. If the user inputs a number less than 5 or greater than 15, the program should continue to ask the user for a valid number within this range.
o Remember that a while loop can be used for input validation.
Once the program has a valid number from the user, it should pass this number as an argument when calling the roll_die function.
roll_die This function should have one parameter, rolls, which represents the number of times to roll the die.
Use a for loop to roll the die the specified number of times.
Use the randint function from the random module to generate a random number between 1 and 20 inclusive.
Print the number of the current roll and the result of the roll as demonstrated in the Sample Output.
o The number of the current roll should start at 1.
o The result of the roll should include the number and either the associated symbol or "CRITICAL HIT!" in the case of the number 20.
Once the for loop has finished, print a message thanking the user for playing.
Run this program. Take a screenshot of the Terminal that includes the line showing where you started the program run with the results. Name the screenshot Lab04P3-ouput.jpg.

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!