Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 1 1 A: All math, all the time Write a method allMath ( ) which takes in two numbers as inputs and returns a

Lab11A: All math, all the time
Write a method allMath() which takes in two numbers as inputs and returns a tuple containing the result of each arithmetic operation between both numbers in the following order: addition, subtraction, multiplication, division, floor division, modulus, power. If one of the operations requires a division by 0, replace its result with None. For example:
allMath(2,3) would return the tuple (5,-1,6,0.6666666666666666,0,2,8)
allMath(1,8) would return the tuple (9,-7,8,0.125,0,1,1)
allMath(6,0) would return the tuple (6,6,0, None, None, None, 1)
allMath(7,8) would return the tuple (15,-1,56,0.875,0,7,5764801)
Outside the method, prompt the user for two numbers, pass those two numbers to allMath, and then print out the result, as the sample outputs below show.
Note: You can assume both inputs are valid numbers (i.e. you dont need to check if the inputs are numbers)
Hint: Remember that, while tuples are immutable, you can concatenate two tuples, much like you would two strings.
Sample outputs (user input in bold):
Enter your first number: 5
Enter your second number: 4
Your resulting tuple is (9,1,20,1.25,1,1,625)

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Verify the formula given for the Pi of the M/M/k.

Answered: 1 week ago

Question

What is the formula to calculate the mth Fibonacci number?

Answered: 1 week ago

Question

What reward policy would you suggest to the university?

Answered: 1 week ago