Answer to Question #267145 in Python for Matteo Villamor

Question #267145

elif op == 7 or op == 8 or op == 9 or op == 10 or op == 11 or op == 12:

a = float(input("Enter the number"))

dict2 = {7: math.fabs(a), 8: math.factorial(a), 9: math.log(

a), 10: math.ceil(a), 11: math.floor(a), 12: math.sqrt(a)}

print("The result is : " + str(dict2.get(op)))

elif op == 13:

print("Functions Menu")

print("a. sin")

print("b. cos")

print("c. tan")



fun = input("Choose the function :")

a = float(input("Enter the angle in radians :"))

dict3 = {'a': math.sin(a), 'b': math.cos(a), 'c': math.tan(a)}

print("The result is : " + str(dict3.get(fun)))


Question:

1. In this program, you are going to create a with getter and setter.


1
Expert's answer
2021-11-18T06:58:33-0500
import math




#creating an input variable

option = int(input("Option (1 ... 13): "))




#if, else conditions for creating calculation

if option == 1 or option == 2 or option == 3 or option == 4 or option == 5 or option == 6:

  a = int(input("Enter first number: "))

  b = int(input("Enter second number: "))

  dict1 = {1: a+b, 2: a-b, 3: a*b, 4: a/b, 5: a % b, 6: a**b}

  print("The result is : " + str(dict1.get(option)))

elif option == 7 or option == 8 or option == 9 or option == 10 or option == 11 or option == 12:

  a = float(input("Enter the number"))

  dict2 = {7: math.fabs(a), 8: math.factorial(a), 9: math.log(

    a), 10: math.ceil(a), 11: math.floor(a), 12: math.sqrt(a)}

  print("The result is : " + str(dict2.get(op)))

elif option == 13:

  print("Functions Menu")

  print("a. sin")

  print("b. cos")

  print("c. tan")







fun = input("Choose the function :")

a = float(input("Enter the angle in radians :"))

dict3 = {'a': math.sin(a), 'b': math.cos(a), 'c': math.tan(a)}

print("The result is : " + str(dict3.get(fun)))


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