Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python 3.4, write a program that adds, subtracts, multiplies, and divides

ID: 640564 • Letter: U

Question

Using Python 3.4, write a program that adds, subtracts, multiplies, and divides two numbers. (These numbers can be chosen by you one number MUST be odd.) If the sum, difference, product, or quotient yields an odd number then use the first number of the chosen as the base and the second number as the power and print the product.

For example:

First number = 13

Second number = 3

13+3 = 16 #No action necessary.

13-3 = 10 #No action necessary.

13*3 = 39 #Raise 13^3 = 2197. Print answer.

13/3 = 4R3 #No action necessary. (Only focus on quotient. Ignore remainders)

Explanation / Answer

import math

def main():
num1 = 13
num2 = 3
if (num1 + num2) % 2 == 1:
print(math.pow(num1, num2))
if (num1 - num2) % 2 == 1:
print(math.pow(num1, num2))
if (num1 * num2) % 2 == 1:
print(math.pow(num1, num2))
if (num1 / num2) % 2 == 1:
print(math.pow(num1, num2))

main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote