Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! coding='utf-8'
- def add(a, b):
- return a+b
- def sub(a, b):
- return a-b
- def mul(a, b):
- return a*b
- def div(a, b):
- return a/b
- def mod(a, b):
- return a%b
- def n_root(n, r):
- return r**(1/n)
- def sin(a):
- return sin(a)
- def cos(a):
- return cos(a)
- def tan(a):
- return tan(a)
- options = {1:add, 2:sub, 3:mul, 4:div, 5:mod, 6:n_root, 7:sin, 8:cos, 9:tan}
- print('Please choose your method: \n')
- print('(1) Addition (2) Subtraction (3) Multiplication (4) Divison')
- print('(5) Modulo (6) n-root (7) Sinus (8) Cosine (9) Tangent')
- choosen = int(input(': '))
- if choosen in options:
- print('\nPlease enter the 2 numbers you want to operate with:')
- print('Please use . (dot) not , (comma) for float.\n')
- if choosen==6:
- print('HINT: For n-root, first number is <n> and second number is <base>')
- print('Example 1: first number: 2, second number: 10 is squareroot of 10')
- print('Example 2: first number: 3, second number: 10 is third root of 10 \n')
- first_number=float(input('First number: '))
- second_number=float(input('Second number: '))
- solution=options[choosen](first_number, second_number)
- print(solution)
- else:
- print('Please choose a operation from 1 to 9')
Advertisement
Add Comment
Please, Sign In to add comment