| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,88 @@ | |||
| 1 | + | ||
| 2 | + # Function to add two numbers | ||
| 3 | + | ||
| 4 | + def add(num1, num2): | ||
| 5 | + | ||
| 6 | + return num1 + num2 | ||
| 7 | + | ||
| 8 | + | ||
| 9 | + # Function to subtract two numbers | ||
| 10 | + | ||
| 11 | + def subtract(num1, num2): | ||
| 12 | + | ||
| 13 | + return num1 - num2 | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + # Function to multiply two numbers | ||
| 17 | + | ||
| 18 | + def multiply(num1, num2): | ||
| 19 | + | ||
| 20 | + return num1 * num2 | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + # Function to divide two numbers | ||
| 24 | + | ||
| 25 | + def divide(num1, num2): | ||
| 26 | + | ||
| 27 | + return num1 / num2 | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + print("Please select operation -\n" \ | ||
| 32 | + | ||
| 33 | + "1. Add\n" \ | ||
| 34 | + | ||
| 35 | + "2. Subtract\n" \ | ||
| 36 | + | ||
| 37 | + "3. Multiply\n" \ | ||
| 38 | + | ||
| 39 | + "4. Divide\n") | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + # Take input from the user | ||
| 45 | + | ||
| 46 | + select = int(input("Select operations form 1, 2, 3, 4 :")) | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + number_1 = int(input("Enter first number: ")) | ||
| 51 | + | ||
| 52 | + number_2 = int(input("Enter second number: ")) | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + if select == 1: | ||
| 57 | + | ||
| 58 | + print(number_1, "+", number_2, "=", | ||
| 59 | + | ||
| 60 | + add(number_1, number_2)) | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + elif select == 2: | ||
| 65 | + | ||
| 66 | + print(number_1, "-", number_2, "=", | ||
| 67 | + | ||
| 68 | + subtract(number_1, number_2)) | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + elif select == 3: | ||
| 73 | + | ||
| 74 | + print(number_1, "*", number_2, "=", | ||
| 75 | + | ||
| 76 | + multiply(number_1, number_2)) | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + elif select == 4: | ||
| 81 | + | ||
| 82 | + print(number_1, "/", number_2, "=", | ||
| 83 | + | ||
| 84 | + divide(number_1, number_2)) | ||
| 85 | + | ||
| 86 | + else: | ||
| 87 | + | ||
| 88 | + print("Invalid input") | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments