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 through Along with a number, each face also has a special symbol or effect associated with it:
If the number on the die is it's considered a "CRITICAL HIT!"
Otherwise, each number is associated with a symbol as follows:
o If the number divides by exactly, the symbol is a Sword.
o If the number divided by has a remainder of the symbol is a Shield.
o If the number divided by has a remainder of the symbol is a Spell.
o If the number divided by has a remainder of 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 and The program will then simulate rolling the die that number of times.
Sample Output:
How many times do you want to roll the die?
Enter a number between and
How many times do you want to roll the die?
Roll : Sword
Roll : Shield
Roll : Spell
Roll : CRITICAL HIT!
Roll : Spell
Roll : Shield
Roll : 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 or greater than 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 rolldie function.
rolldie 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 and 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
o The result of the roll should include the number and either the associated symbol or "CRITICAL HIT!" in the case of the number
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 LabPouput.jpg
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
