0% found this document useful (0 votes)
2 views4 pages

Python Assignment 2

The document contains a Python assignment with eight programming tasks that involve basic input/output operations and conditional statements. Each task includes code snippets that determine properties such as even/odd numbers, absolute values, positivity/negativity, leap years, largest numbers, profit/loss calculations, grading based on marks, and tax calculations. Each task is followed by an example output demonstrating the expected results for given inputs.

Uploaded by

vani.gera2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Python Assignment 2

The document contains a Python assignment with eight programming tasks that involve basic input/output operations and conditional statements. Each task includes code snippets that determine properties such as even/odd numbers, absolute values, positivity/negativity, leap years, largest numbers, profit/loss calculations, grading based on marks, and tax calculations. Each task is followed by an example output demonstrating the expected results for given inputs.

Uploaded by

vani.gera2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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:

print(a,'is a negative no.')


else:
print(a,'= 0')
OUTPUT
Enter the no.0
0=0
Ans 4.

a=int(input('Enter a year: '))


if a%400==0:
print(a,'is a leap year')
elif a%4==0 and a%100!=0:
print(a,'is a leap year')

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:

print(a,'is the largest of the three nos.')


elif b>a and b>c:
print(b,'is the largest of the three nos.')
else:
print(c,'is the largest of the three nos.')

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:

print('No profit, No loss')


elif SP>CP:
print('Profit')
else:
print('Loss')

OUTPUT
Enter the selling price of the product: 870
Enter the cost price of the product: 670
Profit
Ans 7.

a=int(input('Enter the total marks: '))


p=(a/500)*100
if p>=90:
print('A Grade')
elif p>=80 and p<90:

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

You might also like