Python Assignment Solution
Python Assignment Solution
arithmetic_operations()
convert_temperature()
Task 3: Simple Interest Calculator
# Simple Interest Calculator
def calculate_simple_interest():
try:
P = float(input("Enter Principal Amount: "))
R = float(input("Enter Rate of Interest: "))
T = float(input("Enter Time (in years): "))
S = (P * R * T) / 100
print(f"Simple Interest: {S}")
except ValueError:
print("Invalid input! Please enter numeric values.")
calculate_simple_interest()
is_palindrome()
def number_guessing_game():
secret_number = random.randint(1, 100)
attempts = 0
while True:
try:
guess = int(input("Guess the number (1-100): "))
attempts += 1
if guess < secret_number:
print("Too low! Try again.")
elif guess > secret_number:
print("Too high! Try again.")
else:
print(f"Correct! You guessed it in {attempts} attempts.")
break
except ValueError:
print("Invalid input! Please enter a number.")
number_guessing_game()
save_and_read_file()