You are on page 1of 13

OUTPUT :

Which table you want? 14

1X14=14
2X14=28
3X14=42
4X14=56
5X14=70
6X14=84
7X14=98
8X14=112
9X14=126
10X14=140

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:23 PG NO:

Write a Python program to print the multiplication table of


any given number.(using loop)

Program:
a=int(input("Which table you want?"))

for i in range(1,11):
print(i, "x", a, "=", i*a)

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading Program
OUTPUT:

FACTORIAL CALCULATOR

Enter any number: 8

1x2x3x……..x8=40320

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:24 PG NO:
Write a python program to find the factorial of any given
number.(using loop)

Program:
print("\t\tFACTORIAL CALCULATOR")

a=int(input("Enter any number: "))


b=1
for i in range(1,a+1):
b=b*i

print("1 x 2 x 3 x .......", a, "=", b)

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT :

Type any string : LAL KRISHNA ADVANI


Initials in the given string are: L K A

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:25 PG NO:
Write a Python program to accept a name
and display only the initials.

Program:
a=input("Type any string :")

b=a.split()

print("Initials in the given string are:", end='')


for i in b:
print(i[0])

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT :

Type any sentence : Today rain may come

No of words present in the given sentence=4

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:26 PG NO:
Write a Python program to find the number of
words present in the given sentence.

Program:
a=input("Type any sentence :")

b=a.split()

print("No of words in the given sentence =",len(b))

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT :

Type any string : TFA WILL PLAY FOOTBALL MATCH AGAINST ATK CLUB.

Output: The longest word is: FOOTBALL. Its length is 8

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:27 PG NO:
Write a Python program to accept a sentence
and display the longest word present in it along
with its length.

Program:
a=input("Type any string :")

b=a.split()

max=""
for i in b:
if len(i)>len(max):
max=i

print("The longest word is", max, ".Its length is ", len(max))

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT :

Type any string : geeksforgeeks

Output after removing duplicates is: geksfor

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:28 PG NO:
Write a Python program to remove all the
duplicates present in the given string.

Program:

a=input("Type any string :")

b=""

for i in a:
if i not in b:
b=b + i

print("Output after removing duplicates is: ", b)

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT :
Enter the number of datas to be stored in the list ::: 6

Enter 6 numbers:
50
-3
-57
78
90
67

Maximum value in the list is: 90


MInimum value in the list is: -57
Mean of all values in the list = 225/6= 37.5

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:29 PG NO:
Write a program to read a list of n integers. Also find the maximum,
minimum & mean of numeric values stored in a list.
Program:
n= int(input("Enter the number of datas to be stored in the list:"))
L=[]

print("Enter", n , "datas:")
for i in range(n):
a=int(input())
L.append(a)

print(“Maximum value in the list is:”, max(L))


print(“Minimum value in the list is:”, min(L))
print(“Mean of all values in the list =”, sum(L), “/”, n= sum(L)/n)

NOTE:
● Question and Program should be written in the right-hand side using BLUE PEN.
● Underline the heading
OUTPUT:
SEGREGATION PROGRAM
Enter the number of datas to be stored in the list ::: 6

Enter 6 numbers:
50
-3
-57
78
90
67

Datas are: [50, -3, -57, 78, 90, 67]


Positive Datas are: [50, 78, 90, 67]
Negative Datas are: [-3, -57]

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:30 PG NO:
Write a program to segregate positive and negative
numbers of a list in two different lists.
Program:
print("SEGREGATION PROGRAM")
n= int(input("Enter the number of datas to be stored in the list:"))
L=[]

print("Enter", n , "datas:")
for i in range(n):
a=int(input())
L.append(a)

P=[]
N=[]
for i in L:
if i>=0:
P.append(i)
else:
N.append(i)

print("Datas:", L)
print("Positive Datas are:", P)
print("Negative Datas are:", N)
OUTPUT :
DUPLICATE DATA REMOVER
Enter the number of datas to be stored in the list::: 6

Enter 6 numbers:
50
10
20
10
50
50

Original List is: [50, 10, 20, 10, 50, 50]


Modified List is :[50, 10, 20]

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:31 PG NO:
Write a Python program to remove duplicate datas from a list
containing n integers.

Program:
print("SEGREGATION PROGRAM")
n= int(input("Enter the number of datas to be stored in the list:"))
L=[]

print("Enter", n , "datas:")
for i in range(n):
a=int(input())
L.append(a)

L1=[]
for i in L:
if i not in L1:
L1.append(i)

print("Original List:", L)
L=L1
print("Modified List is:", L)
OUTPUT:
Enter the number of datas to be stored in the list ::: 6

Enter 6 numbers:
50
60
70
80
60
100

Enter search element: 60

Search Data is present

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:32 PG NO:
Write a program to search whether the given element is present in the
list or not using LINEAR SEARCH.
Program:
print("SEGREGATION PROGRAM")
n= int(input("Enter the number of datas to be stored in the list:"))
L=[]

print("Enter", n , "datas:")
for i in range(n):
a=int(input())
L.append(a)

x=int(input("Enter search element:"))


flag=0
for i in L:
if i==x:
print("Search Data is present")
flag=1
break

if flag==0:
print("Search Data is not present in the List")
OUTPUT:
Enter the number of datas to be stored in the tuple::: 6

Enter 6 numbers:
10
20
25
28
30
40

Original Tuple is: (10, 20, 25, 28, 30, 40)


Tuple1 formed from the elements present in odd location: (20, 28, 40)
Tuple2 formed from the elements present in odd location: (10, 25, 30)

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:33 PG NO:
Write a program to segregate elements present in odd and even
locations of a tuple to two different tuples.
Program:
n= int(input("Enter the number of datas to be stored in the tuple:"))
T=()

print("Enter", n , "datas:")
for i in range(n):
a=int(input())
T=T+ (a,)

O=()
E=()
for i in range(0, len(T)):
if i%2!=0:
O=O + (T[i], )
else:
E=E + (T[i], )

print("Original Tuple is:", T)


print("Tuple1 formed from the elements present in odd location:",O)
print("Tuple2 formed from the elements present in even location:", E)
OUTPUT:
Enter the number of contacts to be stored in the dictionary:3
Enter person name:Abhir
Enter phone number:9999900000
Enter person name:Adhrit
Enter phone number:9888822222
Enter person name:Elija
Enter phone number:7777770000

PHONE BOOK contains: {'Abhir': 9999900000, 'Adhrit': 9888822222, 'Elija':


7777770000}

Enter the name of the person whose contact is to be accessed:Adhrit

Phone number of Adhrit is: 9888822222

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:34 PG NO:
Write a Python Program to access the phone number of a particular person from the
dictionary containing ‘n’ contacts.

Program:
n= int(input("Enter the number of contacts to be stored in the dictionary:"))
CONTACTS={}

for i in range(n):
key=input("Enter person name:")
value=int(input("Enter phone number:"))
CONTACTS.update( {key:value} )

print("PHONE BOOK contains:", CONTACTS)

x=input("Enter the name of the person whose contact is to be accessed:")


print("Phone number of ", x, "is:", CONTACTS[x])
OUTPUT:
Enter the number of employees:4
Enter employee - ID:101
Enter phone number:Steve
Enter employee - ID:100
Enter phone number:Hasan
Enter employee - ID:99
Enter phone number:Akira
Enter employee - ID:88
Enter phone number:Ibhrahim

Dictionary contains: {101: 'Steve', 100: 'Hasan', 99: 'Akira', 88: 'Ibhrahim'}

Employee-ID Employee-Name
88 Ibhrahim
99 Akira
100 Hasan
101 Steve

NOTE: OUTPUT DESIGN should be written in the left-hand side using PENCIL.

EXNO:35 PG NO:
Write a Python Program to display all employees’ information in
ascending order based upon their ID from the dictionary containing ID
and name for ‘n’ employees.
Program:
n= int(input("Enter the number of employees:"))
EMPLOYEE={}

for i in range(n):
ID=int(input("Enter employee - ID:"))
Name=(input("Enter phone number:"))
EMPLOYEE.update( {ID:Name} )

print("Dictionary contains:", EMPLOYEE)

a=sorted(EMPLOYEE)
print("Employee-ID\t\tEmployee-Name")
for i in a:
print(i, "\t\t", EMPLOYEE[i])

You might also like