Class 12 Computer Science Worksheets

Worksheet-1

1. What is a string slice? How is it useful? (2)

2. Distinguish between concatenation and Replication in string .Give an example.(3)

3. What are the Characteristics of a dictionary? (2)

4. The numbered position of a letter in a string is called —————– (1)

5. Difference between Bubble sort and Insertion sort.Give an example. (2)

6. What is the output of this code?

>>>int(“3”+”4”) (1)

a) “7”

b) “34”

c)34

d)24

 

7)Predict the output of the following code snippet?(2)

Y=str(123)

X=”hello”*3

Print (x,y)

X=”hello”+”world”

Y=Len(x)

Print (y,x)

8)  Find the errors. State reasons.(2)

a) t=[1,”a”,9.2]

t[4]=6

 

b) t=”hello”

t[0]=”H”

 

9) If a is (1,2,3). (3)

i) )is a*3 equivalent to a+a+a?

ii) What is the meaning of a[1:1]

iii) what are the difference between a[1:2] and a[1:1]?

 

10) What  does each of the following expression evaluate to? (3)

[“These”,[“are”,”a”],[“few”, “words”],”that”,”we”,”will”,”use”]

a) L[3:4]+L[1:2]

b) L[2][1:].

c) L[1]+L[2]

 

11)The keys of a dictionary must be of ————- types.(1)

a) integer

b) mutable

c) immutable

d) any of these

 

12) What are the membership operator? Give an example.(2)

 

13)The —— function returns all value from key:value pair of dictionary.(1)

 

 

Worksheet-2

 

1. What is a function?(2)

 

2. Which of the following keywords Marks the beginning of the function block? (1)

a) func

b)define

c)def 

d) function

 

3.Find out the output for the code fragment. (2)

import math

def area(r):

return math.pi*r*r

a=int(area(10))

print(a)

 

4. What are the parts of functions? Explain with a suitable example.(3)

 

5. A———— is a subprogram that acts on data and often returns a value.(1)

 

6. What are the comments? What are the role comments in the program? How to write single-line comments and multi-line comments? (2)

 

7. What is a variable defined outside all the functions referred to as? (1)

 

8. Find the errors in the code snippet. (2)

def in(x,y):

x=x + y

print(x.y)

x*=y

print(x**y)

 

9. Find the errors in the code fragment. (1)

void get(x=10,y):

x = x + y

print(x,n,y)

 

10. Find out the Output for the code fragment. (1)

def Fun1():

print(‘Python, let\’s fun with functions’)

Fun1()

 

11. Differentiate between parameters and arguments. (2)

 

12. What are the arguments supported by python? (2)

 

13. What is the local variable and global variable? Explain with an example. (3)

 

14. What is scope ? What is the scope resolving rule of Python ? (2)

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top