diff --git a/add two number b/add two number new file mode 100644 index 0000000..8fbba12 --- /dev/null +++ b/add two number @@ -0,0 +1,10 @@ +# This program adds two numbers + +num1 = 1.5 +num2 = 6.3 + +# Add two numbers +sum = num1 + num2 + +# Display the sum +print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) diff --git a/solve quadratic b/solve quadratic new file mode 100644 index 0000000..9304927 --- /dev/null +++ b/solve quadratic @@ -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)) diff --git a/swap in python b/swap in python new file mode 100644 index 0000000..22a78b5 --- /dev/null +++ b/swap in python @@ -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))