Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help ASAP please! Write a Python script that will continually prompt for a string in the following format and do the necessary calculations based

Need help ASAP please!

Write a Python script that will continually prompt for a string in the following format and do the necessary calculations based on the given operator using a separate function for each operator. It should be able to perform addition, subtraction, multiplication, division, exponentiation (where first number is base and second is power), modulo.

Input string

Expected output of script

Enter calculation: add 1 2 3 4

Enter calculation: sub 20 30 100 50

Enter calculation: mul 60 7

Enter calculation: div 10 5

Enter calculation: exp 3 2

Enter calculation: mod 3 12

Sum: 10

Difference: -160

Product: 420

Quotient: 2

Power: 9

Modulus: 3

Write a Python script that will simulate a dice roll. It should prompt for a number of sides and then return a random number that might be rolled with a die of that number of sides. Assume a standard die that starts at 1 and goes to the given number of sides.

Input string

Expected output of script

Enter number of sides: 4

Enter number of sides: 6

Enter number of sides: 20

Roll: 2

Roll: 4

Roll: 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago