0% found this document useful (0 votes)
0 views9 pages

Homework

The document contains a series of programming exercises that involve user input and conditional logic in Python. Tasks include calculating bonuses based on salary, determining grades based on marks, checking character types, and calculating tax based on income. Each exercise is accompanied by example inputs and outputs to demonstrate functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views9 pages

Homework

The document contains a series of programming exercises that involve user input and conditional logic in Python. Tasks include calculating bonuses based on salary, determining grades based on marks, checking character types, and calculating tax based on income. Each exercise is accompanied by example inputs and outputs to demonstrate functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

HOMEWORK

NAME: COLACO SAVIO DOMACIANO VICTOR


INTERNSHIP ID: 250527
BRANCH: THANE

# 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

# input a character and check if it is a vowel or consonant.


a="python is a easy language"
v=0
c=0
for i in a:
if i in "aeiouAEIOU":
v+=1
else:
c+=1
print(c)
print(v)
output:

16
9

#Input units and calculate bill using tiered rates


units = float(input("Enter units: "))
if units <= 100:
bill = units * 5
elif units <= 200:
bill = 100 * 5 + (units - 100) * 7
else:
bill = 100 * 5 + 100 * 7 + (units - 200) * 10
print("Bill amount:", bill)

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

# Input weight and height and print health category.


w = float(input("Enter weight (kg): "))
h = float(input("Enter height (m): "))
bmi = w / (h * h)
if bmi < 18.5:
print("Underweight")
elif bmi < 25:
print("Normal")
elif bmi < 30:
print("Overweight")
else:
print("more weight")
output:
Enter weight (kg): 79
Enter height (m): 166
Underweight

# Input a character and check if it is uppercase, lowercase, digit, or special


character.
a = input("Enter a character: ")

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

# Input marks and assign grades


mks = int(input("Enter marks: "))
if mks >= 90:
print("Grade a")
elif mks >= 80 or mks <=89:
print("Grade b")
elif mks >= 70 or mks <=79:
print("Grade c")
elif mks >= 60 or mks <=69:
print("Grade d")
else:
print("Grade f")
output:
Enter marks: 89
Grade b

# Input 3 angles and check if they form a triangle (sum = 180).


a = int(input("Angle 1: "))
b = int(input("Angle 2: "))
c = int(input("Angle 3: "))
if a + b + c == 180:
print(" triangle")
else:
print("not triangle")
output:
Angle 1: 60
Angle 2: 70
Angle 3: 80
not triangle
# Input a number and check whether it has an odd or even number of digits.
num = input("Enter number: ")
if len(num) % 2 == 0:
print("Even")
else:
print("Odd")
output:
Enter number: 10
Even

# Input a number and check if it's a palindrome (e.g., 121, 1221).


num = input("Enter number: ")
if num == num[::-1]:
print("Palindrome")
else:
print("Not a palindrome")

output:
Enter number: 1221
Palindrome

#Determine Age Group


age = int(input("Enter age: "))

if age < 13:

print("Child")

elif age < 20:

print("Teen")
elif age < 60:

print("Adult")

else:

print("Senior")

output:

Enter age: 20

Adult

# Input annual income and calculate tax


inc = float(input("Enter income: "))

if inc < 250000:

tax = 0

elif inc <= 500000:

tax = inc * 0.05

elif inc <= 1000000:

tax = inc * 0.2

else:

tax = inc * 0.3

print("Tax:", tax)

output:

Enter income: 10000000

Tax: 3000000.0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy