├── Main.py └── readme.md /Main.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | #add two numbers 4 | def add(num1, num2): 5 | return num1 + num2 6 | 7 | #subtract two numbers 8 | def subtract(num1, num2): 9 | return num1 - num2 10 | 11 | #multiply two numbers 12 | def multiply(num1, num2): 13 | return num1 * num2 14 | 15 | #divide two numbers 16 | def divide(num1, num2): 17 | return num1 / num2 18 | 19 | print("Please select operation -\n" 20 | "1. Add\n" 21 | "2. Subtract\n" 22 | "3. Multiply\n" 23 | "4. Divide\n") 24 | 25 | 26 | # Taking input from the user 27 | select = input("Select operations form 1, 2, 3, 4 :") 28 | 29 | number_1 = int(input("Enter first number: ")) 30 | number_2 = int(input("Enter second number: ")) 31 | 32 | if select == '1': 33 | print(number_1, "+", number_2, "=", 34 | add(number_1, number_2)) 35 | time.sleep(5) #to show the results for 5 seconds before the program exits! 36 | 37 | elif select == '2': 38 | print(number_1, "-", number_2, "=", 39 | subtract(number_1, number_2)) 40 | time.sleep(5) #to show the results for 5 seconds before the program exits! 41 | 42 | elif select == '3': 43 | print(number_1, "*", number_2, "=", 44 | multiply(number_1, number_2)) 45 | time.sleep(5) #to show the results for 5 seconds before the program exits! 46 | 47 | elif select == '4': 48 | print(number_1, "/", number_2, "=", 49 | divide(number_1, number_2)) 50 | time.sleep(5) #to show the results for 5 seconds before the program exits! 51 | else: 52 | print("Syntax Error!") 53 | time.sleep(5) #to show the results for 5 seconds before the program exits! 54 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Python Calculator [![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com) 3 | ### This is a simple python calculator. 4 | --- 5 | ### Requirements 6 | 1. Make sure you have [**Python** ](https://www.python.org/)(Version 3.6 or higher) installed in your system. 7 | 2. Just download and run the main.py file. 8 | 9 | --- 10 | ### Be sure to stargaze the repository and also checkout [My Website](https://rohandas28.github.io/) to contact me. 11 | #### Thank You. 12 | --------------------------------------------------------------------------------