From e6a7918ed3095a9fb50619cb910f96d41ca48e7b Mon Sep 17 00:00:00 2001 From: Leq1 <44335654+Leq1@users.noreply.github.com> Date: Tue, 20 Oct 2020 14:20:49 +0400 Subject: [PATCH 1/5] Create SimpleCalcz --- SimpleCalcz | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SimpleCalcz diff --git a/SimpleCalcz b/SimpleCalcz new file mode 100644 index 0000000..8aed082 --- /dev/null +++ b/SimpleCalcz @@ -0,0 +1,48 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # Take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # Check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + break + else: + print("Invalid Input") From a2894e5c07dda1662165383451aa6b79328b6d18 Mon Sep 17 00:00:00 2001 From: Leq1 <44335654+Leq1@users.noreply.github.com> Date: Tue, 20 Oct 2020 14:22:00 +0400 Subject: [PATCH 2/5] Create SimpleCalcs --- SimpleCalcs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SimpleCalcs diff --git a/SimpleCalcs b/SimpleCalcs new file mode 100644 index 0000000..8aed082 --- /dev/null +++ b/SimpleCalcs @@ -0,0 +1,48 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # Take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # Check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + break + else: + print("Invalid Input") From 4cbbe8cd0b2db60bfb691755ff6abefd0e6d2924 Mon Sep 17 00:00:00 2001 From: Leq1 <44335654+Leq1@users.noreply.github.com> Date: Tue, 20 Oct 2020 21:08:49 +0400 Subject: [PATCH 3/5] Create SimpleCalc --- SimpleCalc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SimpleCalc diff --git a/SimpleCalc b/SimpleCalc new file mode 100644 index 0000000..8aed082 --- /dev/null +++ b/SimpleCalc @@ -0,0 +1,48 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # Take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # Check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + break + else: + print("Invalid Input") From a4d96fc6a90de61a5edbd199076f7c5b7fe97da3 Mon Sep 17 00:00:00 2001 From: Leq1 <44335654+Leq1@users.noreply.github.com> Date: Tue, 20 Oct 2020 21:13:50 +0400 Subject: [PATCH 4/5] Create quadratic equation --- quadratic equation | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 quadratic equation diff --git a/quadratic equation b/quadratic equation new file mode 100644 index 0000000..9304927 --- /dev/null +++ b/quadratic equation @@ -0,0 +1,17 @@ +# Solve the quadratic equation ax**2 + bx + c = 0 + +# import complex math module +import cmath + +a = 1 +b = 5 +c = 6 + +# calculate the discriminant +d = (b**2) - (4*a*c) + +# find two solutions +sol1 = (-b-cmath.sqrt(d))/(2*a) +sol2 = (-b+cmath.sqrt(d))/(2*a) + +print('The solution are {0} and {1}'.format(sol1,sol2)) From 5ee601abf3325f1d621a2c2f196e9f7671758413 Mon Sep 17 00:00:00 2001 From: Leq1 <44335654+Leq1@users.noreply.github.com> Date: Tue, 20 Oct 2020 21:15:19 +0400 Subject: [PATCH 5/5] Create Swap Two Variables --- Swap Two Variables | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Swap Two Variables diff --git a/Swap Two Variables b/Swap Two Variables new file mode 100644 index 0000000..22a78b5 --- /dev/null +++ b/Swap Two Variables @@ -0,0 +1,16 @@ +# Python program to swap two variables + +x = 5 +y = 10 + +# To take inputs from the user +#x = input('Enter value of x: ') +#y = input('Enter value of y: ') + +# create a temporary variable and swap the values +temp = x +x = y +y = temp + +print('The value of x after swapping: {}'.format(x)) +print('The value of y after swapping: {}'.format(y))