Homework
Homework
# A company gives a 10% bonus if salary > ₹50,000. Take salary input and
show bonus if applicable.
a= float(input("enter the salary:"))
b= 50000
total=0
if a>b:
total=a*10/100
print(f"since salary exceeds 50000, the bonus {total} will be added to your salary which is
{a}")
else:
print("low salary !")
output:-
enter the salary:45000
low salary !
# Take 3 subject marks. If any mark < 35 → Fail. Else if avg > 60 → First
Class, else → Second Class.
a= int(input("enter the marks of subject 1:"))
b= int(input("enter the marks of subject 2:"))
c= int(input("enter the marks of subject 3:"))
avg=0
if a < 35 or b < 35 or c< 35:
print("fail")
else:
avg=a+b+c/3
if avg > 60:
print("First Class")
else:
print("Second Class")
output:
enter the marks of subject 1:67
enter the marks of subject 2:78
enter the marks of subject 3:89
First Class
16
9
output:
nter units: 500
Bill amount: 4200.0
#Take username and password input and verify against stored values.
username = input("Enter username: ")
password = input("Enter password: ")
if username == "admin" and password == "admin":
print("Login successful")
else:
print("Invalid username or password")
output:
Enter username: abc
Enter password: adc
Invalid username or password
#Input three numbers and find the smallest using nested if.
a= int(input("enter the number a:"))
b= int(input("enter the number b:"))
c= int(input("enter the number c :"))
if a <b or c<b:
print("a is smallest")
else:
print("b is smallest")
if a>c or b>c:
print("c is smallest")
output:
enter the number a:23
enter the number b:45
enter the number c :67
a is smallest
#Input amount and apply discount based on slabs.
amt = float(input("Enter amount: "))
if amt >= 10000:
disc = amt * 0.2
elif amt >= 5000:
disc = amt * 0.1
else:
disc = amt * 0.05
print("Discount:", disc)
print("Final amount:", amt - disc)
output:
Enter amount: 20000
Discount: 4000.0
Final amount: 16000.0
if a.isupper():
print("Uppercase")
elif a.islower():
print("Lowercase")
elif a.isdigit():
print("Digit")
else:
print("Special character")
output:
Enter a character: @
Special character
output:
Enter number: 1221
Palindrome
print("Child")
print("Teen")
elif age < 60:
print("Adult")
else:
print("Senior")
output:
Enter age: 20
Adult
tax = 0
else:
print("Tax:", tax)
output:
Tax: 3000000.0