repl.it
@DarthVilgot/

Calculator 1

Python

A bad calculator. My first time coding.

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import math

def calcu():
  x = 0
  y = 0
  operator = ""
  x = int(input("Enter number: "))
  operator = input(str("Enter operator: "))
  y = int(input("Enter number: "))
  if(operator == "/"):
    print(x / y)
  if(operator == "//"):
    print(x // y)
  if(operator == "+"):
    print(x + y)
  if(operator == "-"):
    print(x - y)
  if(operator == "%"):
    print(math.fmod(x, y))
  if(operator == "*"):
    print(x * y)
  if(operator == "**"):
    print(x ** y)

def calc():
  roota = ""
  roota = input(str("Roots?: "))
  if roota == "Yes":
    b = 0
    c = 0
    c = int(input("Which number?: "))
    b = int(input("To the xth root: "))
    print(c ** (1/b))
  else:
    x = int(input("Enter number: "))
    operator = input(str("Enter operator: "))
    if(operator == "!"):
      print(math.factorial(x))

a = ""
a = input(str("1 or 2 numbers: "))
if (a == "2"):
  calcu()
if (a == "1"):
  calc()
?