Lab Manual Grade XI
Lab Manual Grade XI
Aim:
Source Code:
print("\t\t\t\t BIO DATA")
name=input("Enter your Name : ")
age=int(input("Enter age : "))
dob=input("Enter Date of Birth : ")
bg=input("Enter Blood Group : ")
fname=input("Enter Father's Name : ")
mname=input("Enter Mother's Name : ")
addr=input("Enter Address : ")
ph=input("Enter Phone Number : ")
print("Name : ",name)
print("Age : ",age)
print("DOB : ",dob)
print("Blood Group : ",bg)
print("Father's Name : ",fname)
print("Mother's Name : ",mname)
print("Address : ",addr)
print("Phone Number : ",ph)
Output:
BIO DATA
Enter your Name : Ram
Enter age : 25
Result:
Thus the program has been executed successfully
Ex. No. : 2 SIMPLE INTEREST
Aim:
To Write a Python Script to calculate the value of simple
interest.
Source Code:
p=eval(input("Enter Principle Amount : "))
n=eval(input("Enter No. of Years : "))
r=eval(input("Enter Rate of Interest : "))
simp_Int=(p*n*r)/100
print("Simple Interest = ",simp_Int)
Output:
Result:
Thus the program has been executed successfully .
Ex. No. : 3 STUDENT MARKLIST
Aim:
Source Code:
print("Name = ",name)
print("Class & Section = ",clas)
print("Total = ",total)
print("Average = ",avg)
Output:
Enter Mark 3 : 83
Enter Mark 4 : 72
Enter Mark 5 : 86
Name = Hariharan
Class & Section = 11 A
Total = 381
Average = 76.2
Result:
Thus the program has been executed successfully .
Ex. No. : 4 Arithmetic Operations
Aim :
To Write a Python Script to perform arithmetic operations
based on user’s choice.
Source Code:
a=int(input("Enter Number 1 : "))
b=int(input("Enter Number 2 : "))
print("1.Addition")
print("2.Subtraction")
print("3.Multiplication")
print("4.Division")
ch=int(input("Enter your Choice : "))
if ch==1:
print("Sum = ",a+b)
elif ch==2:
print("Difference = ",a-b)
elif ch==3:
print("Product = ",a*b)
elif ch==4:
print("Quotient = ",a/b)
else:
print("Invalid Choice")
Output:
Enter Number 1 : 5
Enter Number 2 : 3
1.Addition
2.Subtraction
3.Multiplication
4.Division
Enter your Choice : 3
Product = 15
Result:
Thus the program has been executed successfully .
Ex. No. : 5 Factorial of a given Number
Aim:
To Write a Python Script to find the factorial of a given number
Source Code:
f=1
n=int(input("Enter an Integer : "))
for i in range(1,n+1):
f=f*i
print("Factorial of Given Value = ",f)
Output:
Enter an Integer : 5
Factorial of Given Value = 120
Result:
Thus the program has been executed successfully.
Ex. No. : 6 Fibonacci Series
Aim:
To Write a Python Script to print the Fibonacci series upto nth
term
Source Code:
n=int(input("Enter N value : "))
a=-1
b=1
print("\t Fibonacci Series")
for x in range(1,n+1):
c=a+b
print(c)
a=b
b=c
Output:
Enter N value : 8
Fibonacci Series
0
1
1
2
3
5
8
13
Result:
Thus the program has been executed successfully and the output is
verified
Ex. No. : 7 Largest of 3 Numbers
Aim:
To Write a Python Script to find the largest number amongst 3
given numbers
Source Code:
a=int(input("Enter Number 1 :"))
b=int(input("Enter Number 2 :"))
c=int(input("Enter Number 3 : "))
if a>b and a>c:
print("Biggest Number = ",a)
elif b>c:
print("Biggest Number = ",b)
else:
print("Biggest Number = ",c)
Output:
Enter Number 1 : 5
Enter Number 2 : 23
Enter Number 3 : 54
Biggest Number = 54
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 8 Pattern Display
Aim:
Source Code:
for i in range(5):
for j in range(5):
if j<=i:
print("*",end=" ")
print()
Output:
*
**
***
****
*****
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 9 ARMSTRONG NUMBER
Aim:
To Write a Python Script to check whether the given number is
palindrome or not.
Source Code:
n=int(input("Enter a Number : "))
a=n
b=0
while a>0:
r=a%10
b=b+(r**3)
a=a//10
if n==b:
print("Given Number is Armstrong No. ")
else:
print("Given Number is Not an Armstrong No.")
Output:
Enter a Number : 143
Result:
Thus the program has been executed successfully and the
output is verified.
Ex.No. 10 Counting No. of letters & Digits
Aim:
To Write a Python Script to print the number of Alphabets
and digits from the given string.
Source Code:
s1=input("Enter a String : ")
digit=0
words=0
letters=0
z=s1.split()
words=len(z)
for x in s1:
if x.isalpha():
letters+=1
elif x.isdigit():
digit+=1
print("No. of Letters : ",letters )
print("No. of Digits : ",digit )
Output:
Enter a String : This is example number 256
No. of Alphabets : 19
No. of Digits : 3
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 11 Removing Vowels from a string
Aim:
To Write a Python Script to remove the vowels from a string.
Source Code:
s1=input("Enter a String : ")
s2=" "
for x in s1:
if x not in "aeiouAEIOU":
s2=s2+x
print("Given String : ",s1)
print("After removing Vowel : ", s2)
Output:
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 12 Removing Duplicates from a List
Aim:
To Write a Python Script to remove the duplicate elements
from a list.
Source Code:
Output:
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 13 Shifting Odd Numbers to left and even to right
Aim:
To Write a Python Script to shift all the odd numbers to the left
and even numbers to the right in a given list of numbers.
Source Code:
list1=eval(input("Enter a Numbered List : "))
odd=[]
even=[]
for x in list1:
if x%2==0:
even+=[x]
else:
odd+=[x]
print("Resultant List : ",odd+even)
Output:
Enter a Numbered List : [1,2,3,4,5]
Resultant List : [1, 3, 5, 2, 4]
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 14 Number and its Square – List of Tuples
Aim:
To Write a Python Script to Create List of Tuples with the First
Element as the Number and Second Element as the Square of the
Number.
Source Code:
n=eval(input("Enter Number of Elements for the list : "))
l1=[]
for x in range(1,n+1):
f=int(input(“Enter the value”))
t1=(f, f*f)
l1=l1+ [t1]
print("Required List of Tuples : ",l1)
Output:
Result:
Thus the program has been executed successfully and the
output is verified.
Ex. No. : 15 Sum of the Values of Dictionary
Aim:
To Write a Python Script to find the sum of all values
in a dictionary
Source Code:
d1=eval(input("Enter Dictionary Elements : "))
s=0
for x in d1.values():
s+=x
print("Sum of the Values of Dictionary : ",s)
Output:
Result:
Thus the program has been executed successfully and the
output is verified.