| 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,71 @@ | |||
| 1 | + def add(x, y): | ||
| 2 | + | ||
| 3 | + """This function adds two numbers"" | ||
| 4 | + | ||
| 5 | + return x + y | ||
| 6 | + | ||
| 7 | + def subtract(x, y): | ||
| 8 | + | ||
| 9 | + """This function subtracts two numbers""" | ||
| 10 | + | ||
| 11 | + return x - y | ||
| 12 | + | ||
| 13 | + def multiply(x, y): | ||
| 14 | + | ||
| 15 | + """This function multiplies two numbers""" | ||
| 16 | + | ||
| 17 | + return x * y | ||
| 18 | + | ||
| 19 | + def divide(x, y): | ||
| 20 | + | ||
| 21 | + """This function divides two numbers""" | ||
| 22 | + | ||
| 23 | + return x / y | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + print("Select operation.") | ||
| 28 | + | ||
| 29 | + print("1.Add") | ||
| 30 | + | ||
| 31 | + print("2.Subtract") | ||
| 32 | + | ||
| 33 | + print("3.Multiply") | ||
| 34 | + | ||
| 35 | + print("4.Divide") | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + choice = input("Enter choice(1/2/3/4):") | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + num1 = int(input("Enter first number: ")) | ||
| 44 | + | ||
| 45 | + num2 = int(input("Enter second number: ")) | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + if choice == '1': | ||
| 50 | + | ||
| 51 | + print(num1,"+",num2,"=", add(num1,num2)) | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + elif choice == '2': | ||
| 56 | + | ||
| 57 | + print(num1,"-",num2,"=", subtract(num1,num2)) | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + | ||
| 61 | + elif choice == '3': | ||
| 62 | + | ||
| 63 | + print(num1,"*",num2,"=", multiply(num1,num2)) | ||
| 64 | + | ||
| 65 | + elif choice == '4': | ||
| 66 | + | ||
| 67 | + print(num1,"/",num2,"=", divide(num1,num2)) | ||
| 68 | + | ||
| 69 | + else: | ||
| 70 | + | ||
| 71 | + print("Invalid input") | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments