Write a Python program Write a Python program to Write a Python program to solve
to print "Hello Python". swap two variables. quadratic equation.
1 In [5]: The standard form of a quadratic
print("Hello Python") In [6]: equation is:
Hello Python # Input two variables 2
Write a Python program a = input("Enter the value of �
to do arithmetical the first variable (a): ")
� +��+�=0
operations addition and b = input("Enter the value of
where
division. the second variable (b): ")
# Addition # Display the original values a, b and c are real numbers and
num1 = print(f"Original values: a = �≠0
float(input("Enter the {a}, b = {b}") The solutions of this quadratic equation
first number for # Swap the values using a is given by:
addition: ")) temporary variable 2
num2 = temp = a �
float(input("Enter the a=b (−� ± ( −4�� )/(2�)
second number for b = temp )1/
addition: ")) # Display the swapped import math
sum_result = num1 + values # Input coefficients
num2 print(f"Swapped values: a = a = float(input("Enter coefficient a: "))
print(f"sum: {num1} + {a}, b = {b}") b = float(input("Enter coefficient b: "))
{num2} = {sum_result}") Enter the value of the first c = float(input("Enter coefficient c: "))
Enter the first number variable (a): 5 # Calculate the discriminant
for addition: 5 Enter the value of the discriminant = b**2 - 4*a*c
Enter the second second variable (b): 9 # Check if the discriminant is positive,
number for addition: 6 Original values: a = 5, b = 9 negative, or zero
sum: 5.0 + 6.0 = 11.0 Swapped values: a = 9, b = 5 if discriminant > 0:
# Division Write a Python program to # Two real and distinct roots
num3 = generate a random number. root1 = (-b + [Link](discriminant)) /
float(input("Enter the import random (2*a)
dividend for division: ")) print(f"Random number: root2 = (-b - [Link](discriminant)) /
num4 = {[Link](1, 100)}") (2*a)
float(input("Enter the Random number: 89 print(f"Root 1: {root1}")
divisor for division: ")) Write a Python program to print(f"Root 2: {root2}")
if num4 == 0: convert kilometers to miles. elif discriminant == 0:
print("Error: Division by In [7]: # One real root (repeated)
zero is not allowed.") kilometers = root = -b / (2*a)
else: float(input("Enter distance in print(f"Root: {root}")
div_result = num3 / kilometers: ")) else:
num4 # Conversion factor: 1 # Complex roots
print(f"Division: {num3} kilometer = 0.621371 miles real_part = -b / (2*a)
/ {num4} = {div_result}") conversion_factor = imaginary_part =
Enter the dividend for 0.621371 [Link](abs(discriminant)) / (2*a)
division: 25 miles = kilometers * print(f"Root 1: {real_part} +
Enter the divisor for conversion_factor {imaginary_part}i")
division: 5 print(f"{kilometers} print(f"Root 2: {real_part} -
Division: 25.0 / 5.0 = 5.0 kilometers is equal to {miles} {imaginary_part}i")
Write a Python program miles") Enter coefficient a: 1
to find the area of a Enter distance in kilometers: Enter coefficient b: 4
triangle. 100 Enter coefficient c: 8
In [4]: 100.0 kilometers is equal to Root 1: -2.0 + 2.0i