Answer to Question #338142 in Python for Seen

Question #338142

Create a program that will accept two numbers and print the product, quotient, sum, difference, remainder, exponent and floor division. First number will be the left operand for quotient, difference, remainder, exponent, and floor division. Also, it prints "True" if it satisfies the condition and "False" otherwise: First number is within 10 and 20


Second number is within 10 and 20


1
Expert's answer
2022-05-06T15:34:59-0400
from math import log

# manual input
# a = int(input("a = "))
# b = int(input("b = "))

def numbers(a, b):
    if a > 20 or a < 10 or b > 20 or b < 10:
        print("False")
    else:
        print("True")


    print(f"product {a}*{b} = {a*b}")
    print(f"quotient {a}/{b} = {a/b}")
    print(f"sum {a}+{b} = {a+b}")
    print(f"difference {a}-{b} = {a-b}")
    print(f"exponent {a}^n = {b} ==> n = {log(b, a)}")
    # if you need b^n = a then replace last line with this one:
    # print(f"exponent {b}^n = {a} ==> n = log(a, b")
    print(f"floor division [{a}/{b}] = {a//b}")

a = 25
b = 12

numbers(a, b)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS