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

Practical File (Class 11)

Uploaded by

Priyanshu Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Practical File (Class 11)

Uploaded by

Priyanshu Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Program 1

Write a program to input length and breadth and print area and
perimeter of rectangle.
Solution:
l=int(input("enter length"))
b=int(input("enter breadth"))
a=(l*b)
b=2*(l+b)
print("area is=",a)
print("perimeter is=",b)
Output
Program 2
Write a program to input radius and print area and
circumference of circle.
Solution:
import math
r=int(input('Enter radius'))
a=math.pi*r*r
print('area of circle=',a)
c=2*math.pi*r
print('circumference of circle=',c)
Output:
Program 3
Write a program to input two number and print the greater
number.
Solution:
a=int(input("enter a no"))
b=int(input("enter a no"))
if a>b:
print("greater no is",a)
else:
print("greater no is",b)

Output
Program 4
Write a program to input a number and check number is
perfect square or not .
Solution:
import math
a=int(input("enter first no"))
b=math.sqrt(a)
if(b*b==a):
print("perfect square")
else:
print("not perfect square")

Output
Program 5
Write a program to Input Year And Check Year Is Leap Year Or
Not.
Solution:
a=int(input("Enter a year="))
if ((a%4==0) and (a%100!=0) ) or (a%400==0):
print(“Leap Year”)
else:
print(“Not A leap Year)
Output
PROGRAM 6
Write a program to input two number and swap them
without using 3rd variable.
SOLUTION:
a=int(input("Enter a number"))
b=int(input("Enter a number"))
print("before Swapping")
print("a=",a)
print("b=",b)
a=a+b
b=a-b
a=a-b
print("After Swapping")
print("a=",a)
print("b=",b)
Output
Program 7
Write a program to display all odd values
upto 15 to 50.
Solution:
for i in range(15,50,2):
if(i%2!=0):
print(i)
Output
Program 8
Write a program to input a number and print Fibonacci
series.
Solution:
n=int(input("Enter a number"))
a=0
b=1
print(a,"\n",b)
for i in range (1,n+1):
c=a+b
print(c)
a=b
b=c
Output
Program 9
Write a program to input a number and check
number is Armstrong number or not.
Solution:
import math
n=int(input("Enter a number="))
sum=0
size=0
a=b=n
while(a>0):
size=size+1
a=a//10
while(b>0):
c=b%10
sum=sum+math.pow(c,size)
b=b//10
if(sum==n):
print("Armstrong number")
else:
print("Not Armstrong number")

Output
Program 10
Write a program to input a number and print its
reverse number. Also check number is palindrome
or not.
Solution:
n=int(input("Enter a number="))
rev=0
a=n
while(a>0):
rev=rev*10+a%10
a=a//10
print("Reverse Number=",rev)
if(rev==n):
print("Palindrome number")
else:
print("Not Palindrome number")
Output
Program 11
Write a program to input a number and check
number is prime or not.
Solution:
n=int(input("Enter a number="))
flag=0
for i in range(2,n):
if n%i==0:
flag=1
break
if(flag==0):
print("Prime number")
else:
print("Not Prime number")
Output
Program 12
Write a menu driven program and perform the following options:-
1. Sum of n number
2. Square root of number
3. Factorial of a number

Solution:
import math
sum=0
fact=1
a=int(input("Enter a number="))
print("Menu")
print("1 for Sum of n number")
print("2 for Square Root of a number")
print("3 for Factorial of a number")
ch=int(input("Enter choice="))
if(ch==1):
for i in range(1,a+1):
sum=sum+i
print("Sum of n number=",sum)
elif(ch==2):
print("square root=",math.sqrt(a))
elif(ch==3):
for i in range(a,0,-1):
fact=fact*i
print("Factorial=",fact)
else:
print("Wrong Choice")
Output

You might also like