Ip Practicals - Copy1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 51

INFORMATION PRACTICE:

{PRACTICALS}

INDEX: -
NAME OF DATE: -
PRACTICALS

S.NO
PRINT TWO VARIABLES & 25/6/2021
1. PUT VALUES INTO THEM.
PRINT THE DATA OF
2. ANNUAL SALES OF A
25/6/2021

COMPANY.

WRITE A PROGRAMM TO 7/7/2021


3. ENTER YOUR PARENTS
AND YOUR AGE.
PRINT THE AREA OF THE 7/7/2021
4. CIRCLE AND ENTER ITS
RADIUS.
PRINT THE MARKS AND 7/7/2021
5. AVERAGE MARKS OF 3
SUBJECT.
ENTER MARKS OF 5
6.
9/7/21
SUBJECTS & PRINT- (you
are eligible for this
scholarship)
ENTER YOUR AGE IF YOU
7.
9/7/21
ARE ABOE 18 & PRINT-
(a message you are eligible
to board)
ENTER POPULATION OF A
8. STATE & ENTER THE
12/7/21

POPULATION IN %’S

ENTER TWO NUMBERS


9. AND PRINT THE
13/7/21

LARGEST NUMBER.
ENTER THREE NUMBERS
10. AND PRINT THEM INTO
13/7/21

ASCENDING ORDER.
ENTER A PROGRAMME
11. TO CHECK WHETHER
15/7/21

THE YEAR IS LEAP YEAR


OR NOT.
WRITE A PROGRAMME 26/7/21
12. TO PRINT THE NATURAL
NUMBERS FROM 1-10.
WRITE A PROGRAMME 26/7/21
13. TO PRINT THE NATURAL
NUMBERSFROM
100 -125.
WRITE A PROGRAMME IN 27/7/21
14. PYTHON TO DISPLAY –
10,20,30,40, 50...N
WRITE A PROGRAMME 27/7/21
15. TO PRINT A SERIES –5, -
4, -3, -2, -1
edit the same program in 30/7/21
16. which the output is given
like this

Write a programme to
17. enter the rate. Calculate 3O/7/21
the simple interest for the
1st few years.
Write a programme using
18. while loop for printing the 31/7/21
sum of natural numbers
from 1 to 100.
Write a programme using
19. for loop for all numbers 31/7/21
divisible by 5 till 100.
Write a programme to print
20. the programme as specifies 31/7/21
below.
Write a programme to print
21. the pattern specified
31/7/21

below.
Write a programme to
22. enter a starting no. Of 10/8/21
range using while loop,
display the no. & the
message.
write a programme to print
23. the sum of even numbers
10/8/21

from 100 –200


write a programme to print
24. all the numbers divisible by
12/8/21

5 I the same line till 100.

write a program to print as 12/8/21


25. specified below.
prepare a list with the
26. following series. 13/8/21

write a programme to
27. enter 2 numbers from
15/08/21

user.
write a programme to
28. declare a dictionary
15/08/21
containing roll number and
names of your 3 friends.

write a programme in
29. python to enter the name 18/08/21
and roll number of 3
students and store them in
a dictionary.
write a python programme
30. to any dictionary 6/09/21
containing roll numbers of
your three friends.
write python programme
31. to enter the numbers as 6/09/21
keys and name of ten
friends as values.
write a programme to
32. create a blank dictionary 7/09/21
and allow the user to enter
any 2 values.

write a programme in
33. python to display the 9/09/21
second element of the
dictionary.
edit the same programme
34. in which the output is 9/09/21
given like this.
write a programme to
35. enter all the vowels of
english language and one 13/09/21
word associated with
each vowel.
Create a dictionary in
36. which the team names are
the keys and the number 13/09/21
of gold medals is the
value.
Create a dictionary whose
37. keys are month names
and whose values are 14/09/21
number of days in each
Month.

KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20

# PRACTICAL -1:
Q) Write a programme in python to define two
variables and store some values into it. Also
print it =

CODE-1:
a=20
b=40
Print (a, b)
OUTPUT-
20 40
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 2:
Q) In an ABC Pvt ltd. company a new
programmer has joined he was assigned to
print the annual sales of that company. Sales
department provided data of quarter wise
sales to the programmer. Help the
programmer to write code =

CODE -2:
a=input ("sales of 1st month")
a1=float(a)
a2=int(a)
b=input ("sales of 2nd month")
c=input ("sales for 3rd month")
d=input ("sales for 4th month")
print ('annual1', a+b+c+d)
print ('anual2', a1*4)
print ('anual3', a2*5)
OUTPUT-
sales of 1st month 15
sales of 2nd month 2000
sales for 3rd month 3000
sales for 4th month 4000
annual1 15200030004000
anual2 60.0 anual3
75
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 3:
Q) Write a programme in python to store the
first names of your parents and your age in
three different variables and print them =

CODE-:
age=input ("enter age")
fname=input ("enter father name")
mname=input ("enter mother name")
print(age,fname,mname)
OUTPUT-
enter age 15
enter father namexyz
enter mother nameabc
15 xyz abc
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 4:
Q) Write a programme in python to enter the
radius of a circle and print the area of the
circle =

CODE -4:
r=int (input ("enter radius of a circle-"))
area= 3.14 *r*r
print(area)
OUTPUT-
Enter the radius of the circle – 25
1962.5
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 5:
Q) Write a programme in python to store the
marks scored by you in English. Your IP
marks are double that of English. The
Political Science marks are 5 marks above
English marks. Print the marks of all 3
subjects and average, consider all are out of
100 =

CODE -5:

a=int (input ("enter marks of English"))


b=a*2
c=a+5
d=(a+b+c)/3
print ("pol sci marks are", b)
print ("eng marks are", a)
print ("ip marks are ", c)
print ("average is ", d)
OUTPUT-
Enter marks of english – 80
Pol sci marks are –60
Eng marks are- 80
Ip marks are – 85
Average is 108.333333333
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 6:
Q) Write a programme to enter marks of 5
subjects, Calculate the average. If the
average is above 75 print a message ‘you are
eligible for a scholarship’=

CODE-6:
eng,mat,pol,ip,acc=85,88,90,92,73
ave=(eng+mat+pol+ip+acc)/5
print(ave)
if (ave>75):
print ("eligible for scholarship")
else:
print ("not eligible for scholarship")
OUTPUT-
85.6
eligible for scholarship
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 7:
Q) Write a programme to enter your age. If
you are above 18 print a message ‘you are
eligible to vote’ =

CODE -7:
age= int (input ("enter your age"))
if (age>18):
print ("eligible to vote")
else:
print ("not eligible to vote")
OUTPUT-
enter your age -20
eligible to vote
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 8:
Q) Write a programme in python to enter the
population of a state. Enter the population in
%. Display a message based on the % =

CODE- 8:
a=int (input ("enter the population in %"))
if (a>90):
print ("thickly populated state and no scope
of anymore industry")
elif (a>75):
print ("thickly populated state but only 5%
new industry can be started")
elif (a>60):
print ("less populated state, can invite more
people from outside and allow them to set up
many new industries")
elif (a>40):
print ("less populated, can invite tourist for
viewing natural beauty, more agricultural
options can be initiated")
OUTPUT-
enter the population in %72
less populated state, can invite more people
from outside and allow them to set up many
new industries.
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 9:
Q) Write a programme in python to enter 2
numbers and print the largest number =

CODE-9:
a=int (input ("enter the value of a"))
b=int (input ("enter the value of b"))
if (a>b):
print(a)
elif (a<b):
print(b)
else:
print(b)
print
a=60
b=40
print ("the largest number")
OUTPUT-
enter the value of a60
enter the value of b40
60
The largest number
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 10:
Q) Write a programme to enter 3 numbers
and print the number in ascending order =

CODE -10:
a=int (input ("enter the value of a"))
b=int (input ("enter the value of b"))
c=int (input ("enter the value of c"))
if (a<b) and (b>c):
print(a,b,c)
elif (b>a) and (c>b):
print(a,c,b)
else:
print(b)
print
a=40
b=60
c=80
print ("a, b and c into ascending order")
OUTPUT-
enter the value of a40
enter the value of b60
enter the value of c80
40 80 60
a, b and c into ascending order
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 11:
Q) Write a programme to enter the year and
check whether the year is leap year or not=

CODE -11:
a=int (input ("enter the year"))
if (a%4==0):
print ("The year is a leap year")
else:
print ("the year is not a leap year")
OUTPUT -
enter the year -2040
The year is a leap year
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 12:
Q) Write a programme to print the natural
numbers from 1-10=

CODE -12:
for i in range (1,11):
print(i)
OUTPUT-
1
2
3
4
5
6
7
8
9
10
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 13:
Q) Write a programme to print natural
numbers from 100-125=

CODE -13:
for i in range (100,126):
print(i)
OUTPUT-
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL – 14:
Q) Write a programme in python to display
10,20,30, 40,50 =

CODE -14:
a=int (input ("enter value of number"))
for i in range (10, a+1,10):
print(i)
OUTPUT-
enter value of number -100
10
20
30
40
50
60
70
80
90
100
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 15:
Q) Write a programme to print a series -5, -
4, -3, -2, -1=

CODE-15:

for i in range (-5,0):


print(i)
OUTPUT-
-5
-4
-3
-2
-1
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20

# PRACTICAL - 16:
Q) edit the same program in which the
output is given like this=
1
12
123
1234
12345

CODE-16:
for i in range (1,6):
for j in range(i):
print (j+1, end='')
print ()
OUTPUT-
1
12
123
1234
12345
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
#PRACTICAL - 17:
Q) write a programme to enter the rate.
Calculate the simple interest for the 1st few
years. Print the interest is the time is 5 years
add 100 rupees to the interest. The principal
amount is 1000. Print simple interest for
every year. (SI=s*t*r/100) =

CODE-17:
r=float (input ("enter rate"))
for t in range (1,11):
s=(1000*t*r)/100
if(t==5):
s=s+100
print ("s for",t,"years",s)
OUTPUT-
enter rate- 500
s for 5 years 25100.0
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 18:
Q) write a programme using while loop for
printing the sum of natural numbers from 1 to
100=

CODE-18:

i=1
sum=0
while(i<101):
sum=sum+i
i=i+1
print ("sum is=", sum)
OUTPUT-
sum is= 5050
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 19:
Q) write a programme using for loop for all
numbers divisible by 5 till 100=

CODE-19:
for i in range (1,101):
if(i%5==0):
print(i,end="")
OUTPUT-
5101520253035404550556065707580859095100
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 20:
Q) write a programme to print the
programme as specifies below=
1
2@
3
4@
5
6@

CODE-20:
for i in range (1,7):
if(i%2==0):
print(i,"@", end="\n")
else:
print(i,end="\n")
OUTPUT-
1
2@
3
4@
5
6@
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 21:
Q) write a programme to print the pattern
specified below=
*
**
***
****
*****

CODE -21:
for i in range (1,5):
for j in range (1,1+1):
print ("*", end="")
print ()
OUTPUT-
*
**
***
****
*****
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 22:
Q) write a programme to enter a starting no.
Of range using while loop, display the no. &
the message, if the no. Is given then display
the no. And the message divisible by 5. if it is
divisible by 5 otherwise display the no. & the
message neither divisible by 2 nor by 5. the
programme must display 5 numbers in each
category=

CODE-22:
a=int (input ("enter the starting number"))
while(a<100):
a+=1
if(a%2==0):
print ("the number is divisible by 2")
elif(a%5==0):
print ("the number is divisible by 5")
else:
print ("the number is neither divisible by
2 nor 5")
OUTPUT-
enter the starting number- 585
the number is divisible by 5
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 23:
Q) write a programme to print the sum of
even numbers from 100 –200=

CODE-23:
sum=0
for i in range (100,201):
if(i%2==0):
sum=sum+i
print ("sum is=", sum)
OUTPUT-
sum is= 7650
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL – 24:
Q) write a programme to print all the
numbers divisible by 5 I the same line till
100=

CODE -24:
for i in range (1,101):
if(i%5==0):
print(i,end="\t")
i+=1

OUTPUT-
5 10 15 20 25 30 35 40 45 50 55
60 65 70 75 80 85 90 95 100
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 25:
Q) write a program to print as specified
below=
1 2 3 4

CODE-25:
for i in range (1,5):
print(i,end="\t")
OUTPUT-
1 2 3 4
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 26:
Q) prepare a list with the following series=

CODE -26:
list1= [1,5,10,20,30]
print(list1)
print(list1[3])
print(list1[3:])
print(max(list1)
OUTPUT-
[1, 5, 10, 20, 30]
20
[20, 30]
30
[1, 5, 10, 20, 30]
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 27:
Q) write a programme to enter 2 numbers
from user=

CODE-27:
list1= []
for i in range (2):
a=int (input ("enter the number"))
print(a)
list1.append(a)
list1.sort()
print(list1)
OUTPUT-
enter the number -9
9
[9]
enter the number -6
6
[6, 9]
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 28:
Q) write a programme to declare a dictionary
containing roll number and names of your 3
friends. Roll numbers are keys and names are
the values. Also display the second element
of dictionary=

CODE-28:
Name=.
{'1':'manasvi','5':'dishita','10':'tanishka'}
print(name)
print (name ['5'])
OUTPUT-
{'1': 'Manasvi', '5': 'Dishita', '10':
'Tanishka'}
Dishita
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL – 29:
Q) write a programme in python to enter the
name and roll number of 3 students and store
them in a dictionary=

CODE -29:
rno=[]
name= []
for i in range (3):
r=int (input ("enter rno"))
n=input ("enter name")
rno.append(r)
name. Append(n)
d={rno[0]:name[0],rno[1]:name[1],rno[2]:name [2]}
print(d)
OUTPUT-
Enter rno- 12
Enter name- anil
Enter rno-34
Enter name- zeb
Enter rno-1
Enter name- gauri
{12:’anil’,34:’zeb’,1:’gauri’}
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 30:
Q) write a python programme to any
dictionary containing roll numbers of your
three friends. Roll number are the keys are
numbers and names are the values=

CODE-30:
NAMES={'1':'SUMA','5':'HINA','8':'RIMA'}
print (NAMES)
OUTPUT-
{'1': 'SUMA', '5': 'HINA', '8': 'RIMA'}
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 31:
Q) write python programme to enter the
numbers as keys and name of ten friends as
values. Show them in dictionary=
i) print the entire dictionary
ii) print the even numbers, dictionary, keys and values.

CODE -31:
rno=[]
name= []
for i in range (4):
r=int (input ("enter rno"))
n=input ("enter name")
rno.append(r)
name.append(n)
d={rno[0]:name[0],rno[1]:name[1],rno[2]:name [2]}
print(d)
print(d.keys())
print(d.values())
print(d.items())
print(d.get(rno[1]))

OUTPUT-
enter rno25
enter name25s
enter rno35
enter name35p
enter rno45
enter name45q
enter rno55
enter name55z
{25: '25s', 35: '35p', 45: '45q'}
dict_keys([25, 35, 45])
dict_values(['25s', '35p', '45q'])
dict_items([(25, '25s'), (35, '35p'),
(45, '45q')])
35p
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 32:
Q) write a programme to create a blank
dictionary and allow the user to enter any 2
values say roll no. and name and store them
in a dictionary to print=

CODE -32:
d= {}
for i in range (2):
r=int (input ("enter the roll no"))
m=input ("enter the name")
d[r]=m
print(d)
print(d.keys())
print(d.values())
print(d.items())
OUTPUT-
enter the roll no-2
enter the name- gauri
enter the roll no-15
enter the name- riya
{2: 'gauri', 15: 'riya'}
dict_keys([2, 15])
dict_values(['gauri', 'riya'])
dict_items([(2, 'gauri'), (15, 'riya')])
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 33:
Q) write a programme in python to display
the second element of the dictionary=

CODE-33:
NAMES={'1':'SUMA','5':'HINA','8':'RIMA'}
print (NAMES)
print (NAMES ['5'])
OUTPUT-
{'1': 'SUMA', '5': 'HINA', '8': 'RIMA'}
HINA
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 34:
Q) edit the same programme in which the
output is given like this=

CODE- 34:
n = int (input ("Enter number of rows: "))
for i in range (1, n+1):
for j in range (1, i+1):
print(i, end="")
print ()
OUTPUT-
Enter number of rows: 5
1
22
333
4444
55555
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 35:
Q) write a programme to enter all the vowels
of english language and one word associated
with each vowel. Print only the vowels from
the dictionary. What will be the data type of
keys and values of dictionary? =

CODE-35:
d= {}
for i in range (5):
a=input ("enter the vowel")
b=input ("enter the word associated with
the vowel")
d[a]=b
print(d)
print(d['e'])
print(d.keys())
print(d.values())
OUTPUT-
Enter the vowel- a
enter the word associated with the vowel -cat
enter the vowel- e
enter the word associated with the vowel -net
enter the vowel- i
enter the word associated with the vowel -sit
enter the vowel- o
enter the word associated with the vowel -owl
enter the vowel -u
enter the word associated with the vowel -put
{'a': 'cat', 'e': 'net', 'i': 'sit', 'o': 'owl', 'u':
'put'}net
dict_keys(['a', 'e', 'i', 'o',
'u'])dict_values(['cat', 'net', 'sit', 'owl', 'put'])
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 36:
Q) in the recent games 4 teams participated.
Enter the names of the teams and the no. Of
gold medals won by the team. Create a
dictionary in which the team names are the
keys and the number of gold medals is the
value. Using for loop to display names of
those teams who have won more than 10
gold medals=

CODE -36:
d= {}
for i in range (4):
name=input ("enter the name of the
team")
medal=int (input ("enter the number of
gold medals"))
d[name]=medal
for i in d:
if d[i]>10:
print(i)
OUTPUT-
enter the name of the team-blue
enter the number of gold medals-12
enter the name of the team-red
enter the number of gold medals-6
enter the name of the team- orange
enter the number of gold medals-8
enter the name of the team -yellow
enter the number of gold medals-15
blue
Yellow
KHWAISH GULATI XI-E 111/09/V ROLL NO. - 20
# PRACTICAL - 37:
Q) - a] create a dictionary whose keys are
month names and its values are the no. of
days in a corresponding month
b] Ask the user to enter a month name and
use the dictionary to tell or to print the no. of
days in that particular month
c] print out all the months which contains 31
days using the dictionary =

CODE-37:

year=
{"jan":31,"feb":28,"march":31,"april":30,"m
ay":31,"june":30,"july":31,"sept":30,"oct":
31,"nov":30,"dec":31}
print(year)
m=input ("enter the month:")
print ("days of the month:", year[m])
OUTPUT-
{'jan': 31, 'feb': 28, 'march': 31, 'april': 30,
'may': 31, 'june': 30, 'july': 31, 'sept': 30,
'oct': 31, 'nov': 30, 'dec': 31}
enter the month: sept
days of the month: 30

You might also like