0% found this document useful (0 votes)
36 views22 pages

11th Class Practical Python Uui Ne W 245

The document describes 21 programming experiments involving Python string manipulation, conditional statements, loops, functions for calculating areas, interest, etc. The experiments cover basic as well as advanced concepts of Python programming language.

Uploaded by

vedwalrajni578
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)
36 views22 pages

11th Class Practical Python Uui Ne W 245

The document describes 21 programming experiments involving Python string manipulation, conditional statements, loops, functions for calculating areas, interest, etc. The experiments cover basic as well as advanced concepts of Python programming language.

Uploaded by

vedwalrajni578
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/ 22

Experiment 1

Write a Python Program to print “Hello World” on Screen.

print (“Hello World “)

Output:
Hello World
Experiment 2
Write a Python Program to print the value of a Variable on Screen.

a = 10
print (“Value of a is = “, a)

Output:
Value of a is = 10
Experiment 3
Write a Python Program to find the Sum of two numbers.

n1 = 5
n2 = 10
sum = a + b
print (“Sum is = “, sum)

Output:
Sum is = 15
Experiment 4
Write a Python Program to find the Sum of two numbers (entered by User).

print (“Enter First Number = ”)


n1 = int (input ( ))
print (“Enter Second Number = ”)
n2 = int (input ( ))
sum = a + b
print (“Sum is = “, sum)

Input:
Enter First Number = 15
Enter Second Number = 20
Output:
Sum is = 35
Experiment 5
Write a Python Program to find the Power of a number to other number (Exponentiation).

print (“Enter the value of Base = ”)


b = int (input ( ))
print (“Enter the value of Power = ”)
p = int (input ( ))
ans = b ** p
print (“Base raise to the Power is = “, ans)

Input 1:
Enter the value of Base = 10
Enter the value of Power = 3
Output 1:
Base raise to the Power is = 1000

Input 2:
Enter the value of Base = 15
Enter the value of Power = 4
Output 2:
Base raise to the Power is = 50625
Experiment 6
Write a Python Program to convert temperature from Celsius int o Fahrenheit.

print (“Enter the Temperature in Celsius = ”)


c = float (input ( ))
f = (c * 9/5) + 32
print (“Equivalent Temperature in Fahrenheit will be = “, f)

Input 1:
Enter the Temperature in Celsius = 95
Output 1:
Equivalent Temperature in Fahrenheit will be = 203.0

Input 2:
Enter the Temperature in Celsius = 37.1
Output 2:
Equivalent Temperature in Fahrenheit will be = 98.78
Experiment 7
Write a Python Program to swap Two numbers entered by the user.

print (“Enter First Number = ”)


n1 = int (input ( ))
print (“Enter Second Number = ”)
n2 = int (input ( ))
t = n1
n1 = n2
n2 = t
print (“After Swapping First Number = ”, n1)
print (“After Swapping Second Number = ”, n2)

Input:
Enter First Number = 5
Enter Second Number = 10
Output:
After Swapping First Number = 10
After Swapping Second Number = 5
Experiment 8
Write a Python Program to calculate the Simple Int erest and Amount for a given Principal, Rate
and Time.

print (“Enter the Principal = ”)


P = float (input ( ))
print (“Enter the Rate of Int erest per annum = ”)
R = float (input ( ))
print (“Enter the Time in Years = ”)
T = float (input ( ))
SI = P * R * T / 100
Amount = P + SI
print (“The Simple Int erest to be paid = “, SI)
print (“The Total Amount to be paid = “, Amount)

Input:
Enter the Principal = 2570
Enter the Rate of Int erest per annum = 3.75
Enter the Time in Years = 4
Output:
The Simple Int erest to be paid = 385.5
The Total Amount to be paid = 2955.5
Experiment 9
Write a Python Program to calculate the Area and Perimeter of a Rectangle.

print (“Enter the Length of Rectangle = ”)


L = int (input ( ))
print (“Enter the Breadth of Rectangle = ”)
B = int (input ( ))
A= L* B
P = 2 * (L + B)
print (“The Area of Rectangle is = “, A)
print (“The Perimeter of Rectangle is = “, P)

Input:
Enter the Length of Rectangle = 15
Enter the Breadth of Rectangle = 12

Output:
The Area of Rectangle is = 180
The Perimeter of Rectangle is = 54
Experiment 10
Write a Python Program to calculate the Area and Circumference of a Circle.

print (“Enter the Radius of Circle = ”)


R = float (input ( ))
A = 3.142 * R * R
P = 2 * 3.142 * R
print (“The Area of Circle is = “, A)
print (“The Perimeter of Circle is = “, P)

Input:
Enter the Radius of Circle = 8.7

Output:
The Area of Circle is = 237.81
The Perimeter of Circle is = 54.67
Experiment 11
Write a Python Program to Check whether the entered Number is Even or Odd?

print (“Enter the Number = ”)


n = int (input ( ))
if n % 2 == 0:
print (“Even Number”)
else:
print (“Odd Number”)

Input 1:
Enter the Number = 5

Output 1:
Odd Number

Input 2:
Enter the Number = 60

Output 2:
Even Number
Experiment 12
Write a Python Program to Check whether the entered Number is ending with 2 Zeros or not?

print (“Enter the Number = ”)


n = int (input ( ))
if n % 100 == 0:
print (“Number is ending with 2 Zeros”)
else:
print (“Number is NOT ending with 2 Zeros”)

Input 1:
Enter the Number = 75089

Output 1:
Number is NOT ending with 2 Zeros

Input 2:
Enter the Number = 68700

Output 2:
Number is ending with 2 Zeros
Experiment 13
Write a Python Program to check Greater among Two Numbers entered by user?

n1 = int (input ((“Enter the First Number = ” ))


n2 = int (input ((“Enter the Second Number = ” ))
if n1 > n2:
print (“First Number is Greater”)
else:
print (“Second Number is Greater”)

Input 1:
Enter the First Number = 15
Enter the Second Number = 20

Output 1:
Second Number is Greater

Input 2:
Enter the First Number = 35
Enter the Second Number = 30

Output 2:
First Number is Greater
Experiment 14
Write a Python Program to Check if for given three angles, Triangle is possible or not.
A1 = int (input ((“Enter the First Angle = ” ))
A2 = int (input ((“Enter the Second Angle = ” ))
A3 = int (input ((“Enter the Third Angle = ” ))
Total = A1 + A2 + A3
if Total == 180:
print (“The given angles will form a Triangle.”)
else:
print (“The given angles will not form a Triangle.”)

Input 1:
Enter the First Angle = 47
Enter the Second Angle = 33
Enter the Third Angle = 100
Output 1:
The given angles will form a Triangle.

Input 2:
Enter the First Angle = 41
Enter the Second Angle = 93
Enter the Third Angle = 23

Output 2:
The given angles will not form a Triangle.
Experiment 15
Write a Python Program to check Greatest among Three Numbers entered by user?

n1 = int (input ((“Enter the First Number = ” ))


n2 = int (input ((“Enter the Second Number = ” ))
n3 = int (input ((“Enter the Third Number = ” ))
if (n1 > n2) and (n1 >n3):
print (“First Number is Greatest”)
elif (n2 > n1) and (n2 >n3):
print (“Second Number is Greatest”)
else:
print (“Third Number is Greatest”)

Input 1:
Enter the First Number = 15
Enter the Second Number = 20
Enter the Third Number = 19

Output 1:
Second Number is Greatest

Input 2:
Enter the First Number = 35
Enter the Second Number = 2
Enter the Third Number = 37

Output 2:
Third Number is Greatest
Experiment 16
Write a Python Program to check a year entered by user is Leap year or not?

a = int (input ("Enter the Year = "))


if (a % 100 == 0 and a % 400 == 0) or (a % 100 != 0 and a % 4 == 0):
print ("Leap Year")
else:
print ("Not a Leap Year")

Input 1:
Enter the Year = 2200

Output 1:
Not a Leap Year

Input 2:
Enter the Year = 1936

Output 2:
Leap Year
Experiment 17
Write a Python Program to check for given three sides of a triangle, is it equilateral, isosceles or
scalene triangle?

a = int (input ("Enter the First Side = "))


b = int (input ("Enter the Second Side = "))
c = int (input ("Enter the Third Side = "))
if (a == b) and (a == c):
print ("It is an Equilateral (Sam bahu) Triangle")
elif (a == b) or (a == c):
print ("It is an Isosceles (Samdwi bahu) Triangle ")
else:
print ("It is a scalene (Visham bahu) Triangle ")

Input 1:
Enter the First Side = 25
Enter the Second Side = 15
Enter the Third Side = 10
Output 1:
It is a scalene (Visham bahu) Triangle

Input 2:
Enter the First Side = 25
Enter the Second Side = 15
Enter the Third Side = 25
Output 2:
It is an Isosceles (Samdwi bahu) Triangle

Input 2:
Enter the First Side = 25
Enter the Second Side = 25
Enter the Third Side = 25
Output 2:
It is an Equilateral (Sam bahu) Triangle
Experiment 18
Write a Python Program to print First 100 Natural numbers.

i=1
print (“First 100 Natural Numbers are:”)
while i <= 1000:
print (i)
i=i+1

Output:
First 100 Natural Numbers are:
1
2
3
4
…….

…..
98
99
100
Experiment 19
Write a Python Program to print table of any number N entered by user.

N = int (input ("Vo number batao, jiska Pahada Likhna hai? = "))
print ("Table of entered number is")
i=1
while i <= 10:
print (N, " x ", i, " = ", N*i)
i=i+1

Input:
Vo number batao, jiska Pahada Likhna hai? = 7

Output:
Table of entered number is
7x1=7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70
Experiment 20
Write a Python Program to find sum of First N Natural Numbers entered by user.

N = int (input ("Enter the Value of N = "))


i=1
sum = 0
while i <= N:
sum = sum + i
i=i+1
print ("Sum of First N Natural Number is = ", sum)

Input 1:
Enter the Value of N = 10

Output 2:
Sum of First N Natural Number is = 550

Input 2:
Enter the Value of N = 90

Output 2:
Sum of First N Natural Number is = 4095
Experiment 21
Write a Python Program to demonstrate Strings in python and its functions.

s = input ("Enter the String = "))


print (“Entered string is = “, s)
print (“Length of Entered string is = “, len (s))
print (“Entered string in Uppercase = “, s. upper())
print (“Entered string in Lowercase = “, s. lower())
print (“Operations and Slicing in Strings”)
print (“First Character of string is = “, s [0])
print (“Third Character of string is = “, s [2])
print (“Fifth Character of string is = “, s [4])
print (“Substring (2nd to 3rd characters) of string is = “, s [1 : 3])
print (“Substring (3rd to 5th characters) of string is = “, s [2 : 5])
print (“Substring (First 4 characters) of string is = “, s [ : 4])
print (“Substring (2nd character and after that) of string is = “, s [1 : ])

Input:
Enter the String = Python

Output:
Entered string is = Python
Length of Entered string is = 6
Entered string in Uppercase = PYTHON
Entered string in Lowercase = python
Operations and Slicing in Strings
First Character of string is = P
Third Character of string is = t
Fifth Character of string is = o
Substring (2nd to 3rd characters) of string is = yt
Substring (3rd to 5th characters) of string is = tho
Substring (First 4 characters) of string is = Pyth
Substring (2nd character and after that) of string is = thon
Experiment 22
Write a Python Program to demonstrate Lists in python and its functions.

list1 = [8, 45, 21, 50, 100, 30]


print (“First List is = “, list1)
print (“Operations and Slicing in First List”)
print (list1[0])
print (list1[4])
print (list1[1: 4])
print (list1[4: 6])
print (list1[5: 6])
print (list1[ : 4])
print (list1[2: ])
list2 = [20, 15, 8, 60, 100, -1]
print (“Second List is = “, list2)
print (“Lenth of the second List is =”, len(list2))
print (“Before Sorting second List is = “, list2)
list2.sort()
print (“After Sorting second List is = “, list2)

Output:
First List is = [8, 45, 21, 50, 100, 30]
Operations and Slicing in First List
8
100
[45, 21, 50]
[100, 30]
[30]
[8, 45, 21, 50]
[21, 50, 100, 30]
Second List is = [20, 15, 8, 60, 100, -1]
Lenth of the second List is = 6
Before Sorting second List is = [20, 15, 8, 60, 100, -1]
After Sorting second List is = [-1, 8, 15, 20, 60, 100]

You might also like