Python Assignment 3
Python Assignment 3
print("Choose an operation:")
print("1. Sine value")
print("2. Cosine value")
print("3. Square root")
print("4. Power of a number")
choice = int(input("Enter your choice (1/2/3/4): "))
if choice == 1:
x = float(input("Enter the value (in radians) to find the sine:
"))
print(f"Sin({x}) = {sin_value(x)}")
elif choice == 2:
x = float(input("Enter the value (in radians) to find the
cosine: "))
print(f"Cos({x}) = {cos_value(x)}")
elif choice == 3:
x = float(input("Enter the value to find the square root: "))
print(f"Square root of {x} = {square_root(x)}")
elif choice == 4:
base = float(input("Enter the base: "))
exponent = float(input("Enter the exponent: "))
print(f"{base} raised to the power {exponent} =
{power(base, exponent)}")
else:
print("Invalid choice. Please choose a valid option.")
OUPUT:
Choose an operation:
1. Sine value
2. Cosine value
3. Square root
4. Power of a number
Enter your choice (1/2/3/4): 1
Enter the value (in radians) to find the sine: 55
Sin(55.0) = -0.999755173
Enter your choice (1/2/3/4): 2
Enter the value (in radians) to find the cosine: 55
Cos(55.0) = 0.0221267563
Enter your choice (1/2/3/4): 3
Enter the value to find the square root: 55
Square root of 55.0 = 7.41619849
Enter your choice (1/2/3/4): 4
Enter the base: 55
Enter the exponent: 55
55.0 raised to the power 55.0 = 5.247445324687519e+95
print("Choose an operation:")
print("1. Factorial")
print("2. Fibonacci Series")
choice = int(input("Enter your choice (1/2): "))
if choice == 1:
num = int(input("Enter a number to find its factorial: "))
print(f"Factorial of {num} is {factorial(num)}")
elif choice == 2:
num = int(input("Enter a number to generate Fibonacci
series up to: "))
print(f"Fibonacci series up to {num}: {fibonacci(num)}")
else:
print("Invalid choice. Please select 1 or 2.")
OUTPUT:
Choose an operation:
1. Factorial
2. Fibonacci Series
Enter your choice (1/2): 1
Enter a number to find its factorial: 55
Factorial of 55 is :
1551118753287382280224243016469303211063259720016
986112000000000000
Choose an operation:
1. Factorial
2. Fibonacci Series
Enter your choice (1/2): 2
Enter a number to generate Fibonacci series up to: 55
Fibonacci series up to 55: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55.
if choice == 1:
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time (in years): "))
si = simple_interest(principal, rate, time)
print(f"Simple Interest: {si}")
elif choice == 2:
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time (in years): "))
n = int(input("Enter the number of times interest is
compounded per year: "))
ci = compound_interest(principal, rate, time, n)
print(f"Compound Interest: {ci}")
else:
print("Invalid choice. Please select 1 or 2.")
OUTPUT:
Choose the type of interest calculation:
1. Simple Interest
Choose the type of interest calculation:
1. Simple Interest
2. Compound Interest
Enter your choice (1/2): 1
Enter the principal amount: 55000
Enter the rate of interest: 5500
Enter the time (in years): 55
Simple Interest: 166,375,000
Choose the type of interest calculation:
1. Simple Interest
2. Compound Interest
Enter your choice (1/2): 2
Enter the principal amount: 55000
Enter the rate of interest: 5500
Enter the time (in years): 55
Enter the number of times interest is compounded per year:
2
Compound Interest: 7.562220173307365e+149