1132220561
Pavan Dange
import math
import cmath
# 1. Accept three inputs and multiple programming languages
def accept_inputs():
three_inputs = input("Enter three values separated by spaces: ").split()
print(f"You entered: {three_inputs}")
languages = input("Enter names of programming languages separated by spaces: ").split()
print("Programming languages entered:", languages)
# 2. Add, subtract, multiply, and divide two numbers
def arithmetic_operations():
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
print(f"Sum: {num1 + num2}")
print(f"Difference: {num1 - num2}")
print(f"Product: {num1 * num2}")
if num2 != 0:
print(f"Quotient: {num1 / num2}")
else:
print("Cannot divide by zero")
# 3. Find square root using the given formula
def find_square_root():
a, b, c = map(float, input("Enter sides a, b, and c separated by spaces: ").split())
s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
print(f"Square root of the area: {area}")
# 4. Swap two numbers using a temporary variable
def swap_numbers():
x, y = input("Enter two numbers separated by spaces: ").split()
temp = x
x=y
y = temp
print(f"Swapped values: x = {x}, y = {y}")
# 5. Find roots of a quadratic equation
def quadratic_roots():
a, b, c = map(float, input("Enter coefficients a, b, and c separated by spaces: ").split())
d = (b ** 2) - (4 * a * c)
root1 = (-b + cmath.sqrt(d)) / (2 * a)
root2 = (-b - cmath.sqrt(d)) / (2 * a)
print(f"Roots of the quadratic equation: {root1}, {root2}")
# 6. Convert kilometers to miles
def km_to_miles():
km = float(input("Enter distance in kilometers: "))
miles = km * 0.621371
print(f"Distance in miles: {miles}")
# 7. Calculate Simple and Compound Interest
def calculate_interest():
P = float(input("Enter the Principal amount: "))
I = float(input("Enter the Interest rate: "))
N = float(input("Enter the Tenure (in years): "))
SI = P * I * N
print(f"Simple Interest: {SI}")
r = I / 100
n = float(input("Enter the number of compounding periods per year: "))
CI = P * (1 + r / n) ** (n * N) - P
print(f"Compound Interest: {CI}")
# 8. Convert Celsius to Fahrenheit
def celsius_to_fahrenheit():
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 1.8) + 32
print(f"Temperature in Fahrenheit: {fahrenheit}")
def main():
accept_inputs()
arithmetic_operations()
find_square_root()
swap_numbers()
quadratic_roots()
km_to_miles()
calculate_interest()
celsius_to_fahrenheit()
if __name__ == "__main__":
main()