0% found this document useful (0 votes)
2 views6 pages

Python Practical File

The document is a practical file for computer science students covering List, Tuple, Dictionary, and Module programs. It includes various programming examples with explanations for each data structure and module usage. The file is organized with an index and provides a total of 35 programs across the mentioned topics.
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)
2 views6 pages

Python Practical File

The document is a practical file for computer science students covering List, Tuple, Dictionary, and Module programs. It includes various programming examples with explanations for each data structure and module usage. The file is organized with an index and provides a total of 35 programs across the mentioned topics.
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

Computer Science Practical File

Topic: List, Tuple, Dictionary and Module Programs

Name: ____________________
Class: XI
Section: ____________
School: ____________________
Index
[Link] Program Page No
1 List Programs (10) 3
2 Tuple Programs (10) 4
3 Dictionary Programs (10) 5
4 Module Programs (5) 6
LIST PROGRAMS
1. Create and print list
a=[10,20,30,40]
print(a)

2. Sum of list
a=[1,2,3,4]
print(sum(a))

3. Largest number
a=[5,9,2,11]
print(max(a))

4. Append
a=[1,2,3]
[Link](4)
print(a)

5. Insert
a=[1,3,4]
[Link](1,2)
print(a)

6. Remove
a=[1,2,3,4]
[Link](3)
print(a)

7. Reverse
a=[1,2,3]
[Link]()
print(a)

8. Sort
a=[5,2,8,1]
[Link]()
print(a)

9. Count
a=[1,2,2,3]
print([Link](2))

10. Copy
a=[1,2,3]
b=[Link]()
print(b)
TUPLE PROGRAMS
1. Create tuple
t=(1,2,3)
print(t)

2. Access
t=(10,20,30)
print(t[1])

3. Length
t=(1,2,3,4)
print(len(t))

4. Count
t=(1,2,2,3)
print([Link](2))

5. Index
t=(5,6,7)
print([Link](6))

6. Concatenate
t1=(1,2)
t2=(3,4)
print(t1+t2)

7. Repeat
t=(1,2)
print(t*3)

8. Check element
t=(1,2,3)
print(2 in t)

9. List to tuple
l=[1,2,3]
t=tuple(l)
print(t)

10. Nested tuple


t=(1,(2,3))
print(t[1][0])
DICTIONARY PROGRAMS
1. Create dictionary
d={"name":"Anish","age":16}
print(d)

2. Access value
d={"a":10,"b":20}
print(d["a"])

3. Add
d={"a":1}
d["b"]=2
print(d)

4. Update
d={"a":1,"b":2}
d["a"]=10
print(d)

5. Remove
d={"a":1,"b":2}
[Link]("a")
print(d)

6. Keys
d={"x":1,"y":2}
print([Link]())

7. Values
d={"x":1,"y":2}
print([Link]())

8. Items
d={"a":1,"b":2}
print([Link]())

9. Check key
d={"a":1,"b":2}
print("a" in d)

10. Loop
d={"a":1,"b":2}
for k,v in [Link]():
print(k,v)
MODULE PROGRAMS
1. Import math
import math
print([Link](16))

2. Factorial
import math
print([Link](5))

3. Random number
import random
print([Link](1,10))

4. Create module
# [Link]
def add(a,b):
return a+b

# main file
import mymodule
print([Link](2,3))

5. Alias import
import math as m
print([Link])

You might also like