-
Notifications
You must be signed in to change notification settings - Fork 51
/
Calculator.rickroll
73 lines (50 loc) · 2.09 KB
/
Calculator.rickroll
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
we know the sys and we're gonna play it
# same as `import sys` in python
# add function
gonna add num1, num2
when i give my num1 + num2 it will be completely
say goodbye
# multiply function
gonna multiply num1, num2
when i give my num1 * num2 it will be completely
say goodbye
# divide function
gonna divide num1, num2
when i give my num1 / num2 it will be completely
say goodbye
# subtract function
gonna subtract num1, num2
when i give my num1 - num2 it will be completely
say goodbye
take me to ur heart
i just wanna tell u how im feeling "Calculator (each token splits with a space)"
# While True loop to keep the calculator going forever until you kill it (^C)
together forever and never to part
# Ask for input
i just wanna tell u how im feeling "\n>>>"
give input up sys.stdin.readline()
# Split input in a list which looks like: [num1, operator, num2]
give input up input.split()
# Save operator to a variable
give operator up input[1]
# Create a num1 and num2 variable and make them floats
give num1 up float(input[0])
give num2 up float(input[2])
# check if operator is "+" and if so run the add function and print the result
and if u ask me how im feeling operator == "+"
i just wanna tell u how im feeling add(num1, num2)
say goodbye
# check if operator is "-" and if so run the subtract function and print the result
and if u ask me how im feeling operator == "-"
i just wanna tell u how im feeling subtract(num1, num2)
say goodbye
# check if operator is "/" and if so run the divide function and print the result
and if u ask me how im feeling operator == "/"
i just wanna tell u how im feeling divide(num1, num2)
say goodbye
# check if operator is "*" and if so run the multiply function and print the result
and if u ask me how im feeling operator == "*"
i just wanna tell u how im feeling multiply(num1, num2)
say goodbye
say goodbye
say goodbye