Python Assignment 2
Python Assignment 2
Ans 1.
a=int(input('Enter the no.'))
if a%2==0:
print(a,'is an even no.')
else:
print(a,'is an odd no.')
OUTPUT
Enter the no.7
7 is an odd no.
Ans 2.
a=int(input('Enter the no.'))
b=a/-1.0
if a>0:
print('Absolute value of',a,'is',a)
else:
print('Absolute value of',a,'is',b)
OUTPUT
Enter the no.-8
Absolute value of -8 is 8
Ans 3.
a=int(input('Enter the no.'))
if a>0:
print(a,'is a positive no.')
elif a<0:
else:
print(a,'is not a leap year')
OUTPUT
Enter a year: 2019
2019 is not a leap year
Ans 5.
a=int(input('Enter the first no.: '))
b=int(input('Enter the second no.: '))
c=int(input('Enter the third no.: '))
if a>b and a>c:
OUTPUT
Enter the first no.: 7
Enter the second no.: 8
Enter the third no.: 6
8 is the largest of the three nos.
Ans 6.
SP=float(input('Enter the selling price of the product: ‘))
CP=float(input('Enter the cost price of the product: '))
if SP==CP:
OUTPUT
Enter the selling price of the product: 870
Enter the cost price of the product: 670
Profit
Ans 7.
print('B Grade')
elif p>=70 and p<80:
print('C Grade')
elif p>=60 and p<70:
print('D Grade')
else:
print('E Grade')
OUTPUT
Enter the total marks: 250
E Grade
Ans 8.
a=int(input('Enter the taxable amount: '))
totaltax_above5lakhs=(5/100)*(500000-300000)+(20/100)*(a-500000)
totaltax_above10lakhs=(5/100)*(500000-300000)+(20/100)*(1000000-
500000)+(30/100)*(a-1000000)
if a<=300000:
total_tax=0
elif a>=300001 and a<=500000:
total_tax=(5/100)*(a-300000)
elif a>=500001 and a<=1000000:
total_tax=totaltax_above5lakhs
else:
total_tax=totaltax_above10lakhs
edu=(3/100)*total_tax
total_income_tax=total_tax+edu
print('Total tax = ',total_income_tax)
OUTPUT
Enter the taxable amount: 700000
Total tax = 51500.0