Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Calculator.py
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
import math def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divided(x,y): return x/y def percentage(x,y): return x%y def power(x,y): return x**y def sqrt(x): return sqrt(x) def factorial(x): return factorial(x) def sin(x): return sin(x) def cos(x): return cos(x) def tan(x): return tan(x) def asin(x): return asin(x) def acos(x): return acos(x) def atan(x): return atan(x) def log10(x): return log10(x) def log(x): return log(x) def randint(x,y): return randint(x,y) print("Select operation.") print('1.add') print('2.subtract') print('3.multiply') print('4.divided') print('5.percentage') print('6.power') print('7.sqrt') print('8.factorial') print('9.sin') print('10.cos') print('11.tan') print('12.asin') print('13.acos') print('14.atan') print('15.log10') print('16.log') print('17.randint') while True: choice = input("Enter choice(1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17): ") if choice in (1,17): num1 = float(input("Enter first number: ")) num2=float(input("Enter second number:")) if choice=='1': print(num1,'+',num2,'=',add(num1,num2) elif choice=='2': print(num1,'-',num2,'=',subtract(num1,num2) elif choice=='3': print(num1,'*',num2,'=',multiply(num1,num2) elif choice=='4': print(num1,'/',num2,'=',divided(num1,num2) elif choice=='5': print(num1,'%',num2,'=',percentage(num1,num2) elif choice=='6': print(num1,'**',num2,'=',power(num1,num2) elif choice=='7': print(math.sqrt(num1)) elif choice=='8': print(math.factorial(num1)) elif choice=='9': print(math.sin(num1)) elif choice=='10': print(math.cos(num1)) elif choice=='11': print(math.tan(num1)) elif choice=='12': print(math.asin(num1)) elif choice=='13': print(math.acos(num1)) elif choice=='14': print(math.atan(num1)) elif choice=='15': print(math.log10(num1)) elif choice=='16': print(math.log(num1)) elif choice=='17': print(math.randit(num1,num2) break else: print("Invalid Input")
[
+
]
Show input
edit mode
|
history
|
discussion