We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7ac7c03 commit 3267d2fCopy full SHA for 3267d2f
Numbers/calc.py
@@ -0,0 +1,22 @@
1
+# -*- coding: cp1252 -*-
2
+"""
3
+Calculator – A simple calculator to do basic operators.
4
5
+
6
+if __name__ == '__main__':
7
+ num1 = input("Number 1: ")
8
+ num2 = input("Number 2: ")
9
+ op = raw_input("Operation (+, -, /, *): ")
10
11
+ if op not in '+-/*':
12
+ print "Invalid operator"
13
+ else:
14
+ if op == '+':
15
+ res = num1 + num2
16
+ elif op == '-':
17
+ res = num1 - num2
18
+ elif op == '/':
19
+ res = num1 / num2
20
+ elif op == '*':
21
+ res = num1 * num2
22
+ print "%d %s %d = %d" % (num1, op, num2, res)
0 commit comments