Rihen Python Experimment 2
Rihen Python Experimment 2
2. Explain the difference between the if, elif, and else statements in
Python. Provide an example to illustrate their usage.
3. How does Python handle nested if statements, and what are some
best practices for using nested decision-making statements to ensure
code readability and maintainability?
Nested If-Else Statement: Classifies a triangle based on the lengths of its sides.
Problem Statements
OUTPUT:
OUTPUT:
OUTPUT:
if(option==1):
print(f"YOUR BALANCE IS {balance}")
elif(option==2):
amount=int(input("ENTER AMOUNT TO DEPOSIT: "))
newBalance=balance+amount print(f"YOUR
UPDATED BALANCE IS: {newBalance}") elif(option==3):
amount=int(input("ENTER AMOUNT TO WITHDRAW: "))
if(amount<=balance):
newBalance=balance-amount print(f"YOUR
UPDATED BALANCE IS: {newBalance}") else:
print("Insufficent balance ")
else:
print("SOMETHING WENT WRONG!!!")
OUTPUT:
Signature of Faculty