0% found this document useful (0 votes)
4 views

python practical 11th cbse

The document contains a comprehensive list of Python programming exercises along with their corresponding code snippets and sample outputs. Each exercise focuses on different programming concepts such as calculations, conditionals, loops, and user input. The exercises range from basic tasks like calculating age to more complex ones like calculating compound interest and determining leap years.

Uploaded by

Nitish Sharma
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)
4 views

python practical 11th cbse

The document contains a comprehensive list of Python programming exercises along with their corresponding code snippets and sample outputs. Each exercise focuses on different programming concepts such as calculations, conditionals, loops, and user input. The exercises range from basic tasks like calculating age to more complex ones like calculating compound interest and determining leap years.

Uploaded by

Nitish Sharma
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/ 36

Index

Question Remarks
write a program in python to calculate in how many year you will be 100 years old.
write a program in python to calculate in which year you will be 100 years old.
write a program in python to calculate area and perimeter of rectangle . Enter by the
user.
write a program in python to calculate the area of circle.
Write a program in python to calculate area of triangle.
Write a program in python to calculate circumference of a circle.
Write a program in python to calculate profit,profit% or loss,loss%.
Write a program in python to check if a number is divisible by another number.
Write a program in python to calculate eligibility of vote according to age.
Write a program in python to check if a number is even or odd.
Write a program in python to calculate factorial of a number.
Write a program in python to calculate distance in meter ,cm,feet,inch.
Write a program in python to calculate time in minute hour and second.
Write a program in python to determine pass or fail.
Write a program in python to print table of number.
Write a program in python to calculate simple interest.
Write a program in python to print invoice of a product.
Write to program in python to calculate sum and percentage in 5 subjects.
Write a program in python to calculate tax on salary.
Write a program in python to convert temperature from faranhiet to Celsius.
Write a program to arrange no in ascending order.
Write a program in python to do all arithmetic operations on two numbers.
Write a program in python to calculate compound interest.
Write a program in python to calculate time from distance and speed.
Write a program in python to determine leap year or not a leap year.
Write a program in python to determine whether a number is positive , negative or
zero.
Write a program in python to calculate cube root of a number.
Write a program in python to calculate square root of a number.
Write a program in python to calculate square of a number.
Write a program in python to calculate cube of a number.
Write a program in python to print your name five times.
Write a program to check if all letters are uppercase.
Write a program in python to show how indexing works.
Write a program to show use of break keyword.
Write a program to show all keywords.
Q1 Write a program in python to calculate in how many year you will be 100 years old.

Code:
NAME=str(input('enter your name = '))
age=int(input('enter your age = '))
years=(100-age)
print('you will turn 100 years old in', years ,' years')

Sample Output:
Q2 write a program in python to calculate in which year you will be 100 years old.

Code:

NAME=str(input('enter your name = '))

age=int(input('enter your age = '))

year= (100-age)+2024
print('you will turn 100 in the year' , year)

Sample Output:
Q3 write a program in python to calculate area and perimeter of rectangle . Enter by the user.

Code:

l=int(input('enter the length of rectangle = '))

b=int(input('enter the breadth of rectangle = '))

area=l*b
print('area = ',area)

perimeter=2*(l+b)

print('perimeter = ',perimeter)

Sample Output:

Q4 write a program in python to calculate the area of circle.


Code:

a=int(input('enter radius ='))

pi=3.14

area=pi*a*a

print('area=',area)

Sample Output:
Q5 Write a program in python to calculate area of triangle.

Code:

b=int(input('enter the base of triangle='))

h=int(input('enter the height of triangle='))

a=(1/2)*b*h
print("Area:",a)

Sample Output:
Q6 Write a program in python to calculate circumference of a circle.
Code:

r=int(input('enter radius = '))

circumference=2*3.14*r

print('circumference = ',circumference)

Sample Output:
Q7 Write a program in python to calculate profit,profit% or loss,loss%.
Code:

CP=int(input('Cost Price'))

SP=int(input('Selling Price'))

Loss=CP-SP

Profit=SP-CP
Losspercent=(CP-SP)/(CP)*100

Profitpercent=(SP-CP)/(CP)*100

if (SP>CP):

print('Profit=',Profit)

print('Profit%=',Profitpercent)
elif(CP>SP):

print('Loss=',Loss)

print('Loss%=',Losspercent)

Sample Output:
Q8 Write a program in python to check if a number is divisible by another number.
Code:

x=int(input('enter 1st no = '))

y=int(input('enter 2nd no = '))

if(x%y==0):

print(x,' is divisible by ',y)


else:

print(x,'is not divisible by',y)

Sample Output:
Q9 Write a program in python to calculate eligibility of vote according to age.
Code:

age=int(input('enter you age = '))

if(age>=18):

print('you can vote')

else:
print('you cannot vote')

Sample Output:
Python Programs And their Output
Q10 Write a program in python to check if a number is even or odd.

Code:

num=int(input('enter the number'))


if(num%2==0):

print('even no')

else:

print('odd no')
Sample Output:
Python Programs And their Output
Q11 Write a program in python to calculate factorial of a number.

Code:

num=int(input('enter any positive no = '))

fact=1

for i in range(num):
fact=fact*(i+1)
print('factorial of ',num,' = ',fact)

Sample Output:
Python Programs And their Output
Q12 Write a program in python to calculate distance in meter ,cm,feet,inch.

Output:

Dis=int(input("Distance in km"))

meter=Dis*1000

feet=Dis*3280.84
inch=Dis*39370.1

cm=Dis*100000

print("distance in meter = ",meter)

print("distance in cm = ",cm)

print("distance in feet = ",feet)


print("distance in inch = ",inch)

Sample Output:
Python Programs And their Output
Q13 Write a program in python to calculate time in minute hour and second.

Code:

Time=int(input('Time in seconds'))

Hours=Time//3600

Minutes=Time//60
Seconds=Time%60

print('Hours=',Hours)

print('Minutes=',Minutes)

print('Seconds=',Seconds)

Sample output:
Python Programs And their Output
Q14 Write a program in python to determine pass or fail.

Code:

marks=int(input("enter percentage of marks = "))


if(marks>=33):

print('you passed')

else:

print('you failed')

Sample Output:
Python Programs And their Output
Q15 Write a program in python to print table of number.

Code:

num=int(input('enter the number for printing table = '))


for i in range(1,11):

print(num,' x ',i,' = ',num*i)

Sample Output:
Python Programs And their Output
Q16 Write a program in python to calculate simple interest.

Code:

p=int(input("enter the principle amount = "))


r=int(input("enter rate of interest = "))

t=int(input("enter the time of borrowing in years = "))

si=(p*r*t)/100

print("simple interest = ",si)

Sample Output:
Python Programs And their Output
Q17 Write a program in python to print invoice of a product.

Code:

item=str(input('enter the name of item: '))


SP=float(input('enter the selling price of item: '))

gst=float(input('enter the gst rate: '))

cgst=SP*((gst/2)/100)

sgst=cgst
amount=SP+cgst+sgst

print('\t Invoice')

print('item:' , item)

print('price:' , SP)
print("CGST (@",(gst/2), "%): ",cgst)

print("SGST (@",(gst/2), "%): ",sgst)

print("amount payable" ,amount)

Sample Output:
Python Programs And their Output
Q18 Write to program in python to calculate sum and percentage in 5 subjects.

Code:

maths=int(input("number in maths = "))


chemistry=int(input("number in chemistry = "))

cs=int(input("number in computer science = "))

physics=int(input("number in physics = "))

english=int(input("number in English = "))


sum=english+maths+cs+chemistry+physics

percentage=(english+maths+cs+chemistry+physics)/500*100

print("sum = ",sum)

print("percentage = ",percentage)

Sample Question:
Python Programs And their Output
Q19 Write a program in python to calculate tax on salary.

Code:

x=int(input('enter the salary = '))


if(x<=50000):

tax =0.05*x

print('tax =',tax)

elif(x<=60000):
tax =0.06*x

print('tax =',tax)

elif(x<=70000):

tax =0.08*x

print('tax =',tax)
else:
tax =0.1*x

print('tax =',tax)

Sample Output:
Python Programs And their Output
Q20 Write a program in python to convert temperature from faranhiet to Celsius.

Code:
Faranhiet=int(input('Temprature in faranhiet = '))

Celcius=(Faranhiet-32)*5/9
print('Temprature In Celsius = ',Celcius)

Sample Output:
Python Programs And their Output
Q21 Write a program to arrange no in ascending order.

Code:

a=int(input("enter the first number"))


b=int(input("enter the second number"))

c=int(input("enter the third number"))

if(a>b>c):

print(c,b,a)
elif(a>c>b):

print(b,c,a)

elif(b>a>c):

print(c,a,b)

elif(b>c>a):
print(a,c,b)

elif(c>b>a):

print(a,b,c)
elif(c>a>b):

print(b,a,c)

Sample Output:
Python Programs And their Output
Q22 Write a program in python to do all arithmetic operations on two numbers.

Code:

a=int(input("first no-"))

b=int(input("second no-"))

sum=a+b
multiplication=a*b

subtract=a-b

division=a/b

mod=a%b

print("sum =",sum)
print("subtract =",subtract)

print("multiplication =",multiplication)

print("division =",division)
print("mod =",mod)

Sample output:

Q23 Write a program in python to calculate compound interest.

Code:
Python Programs And their Output
n = int(input('enter the amount: '))

r = int(input('enter rate of interest: '))

y = int(input('Enter no of year: '))

for i in range(y):

n=n+((n*r)/100)
print("Final amount in ",i+1," years is: ",n)

Sample Output:
Python Programs And their Output
Q24 Write a program in python to calculate time from distance and speed.

Code:

d=float(input('Enter distance in km: '))

s=float(input('Enter speed in km/hr: '))

t=d//s
m=((d/s)-t)*60
print('Time taken to cover ',d,' km is ',t,' hr ',m,' minutes ')

Sample Output:
Python Programs And their Output
Q25 Write a program in python to determine leap year or not a leap year.

Code:

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


if(y%4==0):

print('leap year')

else:

print('not a leap year')


Sample Output:
Python Programs And their Output
Q26 Write a program in python to determine whether a number is positive , negative or zero.

Code:

I=int(input('Enter any number: '))


if(I>0):

print('positive number')

elif(I==0):

print('Zero')
else:

print('negative no')

Sample Output:
Python Programs And their Output
Q27 Write a program in python to calculate cube root of a number.
Code:

a=float(input('Enter any no: '))

b=a**(1/3)

print('Cube root of ',a,' is = ',b)

Sample Output:
Python Programs And their Output
Q28 Write a program in python to calculate square root of a number.
Code:

a=float(input('Enter any no: ')) b=a**(1/2)

print('Square root of ',a,' is = ',b)

Sample Output:
Python Programs And their Output
Q29 Write a program in python to calculate square of a number.
Code:

a=float(input('Enter any no: '))

b=a**2

print('Square of ',a,' is = ',b)

Sample Output:
Python Programs And their Output
Q30 Write a program in python to calculate cube of a number.
Code:

a=float(input('Enter any no: '))

b=a**3

print('Cube of ',a,' is = ',b)

Sample Output:
Python Programs And their Output
Q31 Write a program in python to print your name five times.
Code:
for i in range(5):

print("Nitish Sharma")

Sample Output:
Python Programs And their Output
Q32 Write a program to check if all letters are uppercase.
Code:
str=input('Enter a word: ')

a=str.isupper()
print(a)

Sample Output:
Python Programs And their Output
Q33 Write a program in python to show how indexing works.

Code:

list=[1,2]
print('Positive Index')

print(list[0])

print(list[1])

print('Negative Index')
print(list[-1])

print(list[-2])

Output:
Python Programs And their Output
Q34 Write a program to show use of break keyword.

Code:

for x in "Nitish":
if(x=="i"):

break

print(x)
Output:
Python Programs And their Output
Q35 Write a program to show all keywords.

Code:

import keyword
print(keyword.kwlist)

Sample Output:

You might also like