0% found this document useful (0 votes)
10 views3 pages

Class XI CS Worksheet - I 2025

The document is a Computer Science worksheet for Class XI that contains various coding exercises and questions related to Python programming. It includes tasks such as identifying and correcting errors in code, predicting outputs of code snippets, and understanding string and dictionary methods. The worksheet also tests knowledge on random number generation and data structures in Python.

Uploaded by

varsha.ashwin321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Class XI CS Worksheet - I 2025

The document is a Computer Science worksheet for Class XI that contains various coding exercises and questions related to Python programming. It includes tasks such as identifying and correcting errors in code, predicting outputs of code snippets, and understanding string and dictionary methods. The worksheet also tests knowledge on random number generation and data structures in Python.

Uploaded by

varsha.ashwin321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Date: 08/03/2025 Computer Science Worksheet – I (Class XI)

I Find error in the following code (if any) and correct code by rewriting code and
underline the correction;‐
1. a, b = 0
If (a=b)
a+b = c
Print c

2. The following code has two dictionaries with tuple as keys, While one of these
dictionaries being successfully created, the other is giving some error. Find out
which dictionary will be created successfully and which one will give error and
correct it.
D1 = {(1,2) : [1, 2], (3, 4) : [5, 6] }
D2 = {( [[1], [2] ) : [1, 2], ( [3], [4]) : [5, 6] }

3. Find the output generated by the following code:


a=(2 + 3) ** 3 – 6 / 2
b=(2 + 3) * 5// 4 + (4 + 6) / 2
c=12 + ( 3 * 4 – 6 ) / 3
d=12 % 5 * 3 + (2 * 6) // 3
print(a, b, c, d)

4. Which string method is used to implement the following:

a. To count the number of characters in the string


b. To change the first character of the string in capital letter
c.To change lowercase to uppercase letter
d. To check whether the given character is letter or a number

5. Which of the function return the smallest integer not less than number.
a) exp() b) ceil() c) floor() d) fabs()

6. What is the output of math.ceil(89.7)?


a) 90 b) 7 c) 89 d) 80

7.Out of the following, which function should we use to generate random numbers
between 1 and 5 ?
a) random() b) randint() c) range() d) generate()

8. What will be the output for the following statements?


import random
print(random.random() * 20) + 1 )
A) 21 b) A random integer within the range 0 to 21 c) A random whole
number within the range 1 to 20 d) None
9. What will be the output for the following statements?
import random
X = [‘Monday’, Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’]
print(x [ random.randint(0, len(X) - 1) ] )

a) IndexError
b) A random day from all the seven days
c) A random day from all the days except Sunday
d) A random days from all the days except monday

9. What will be the output of the following code:


D =[ [ [ [1,2], [3, 4] ], [ [5,6], [7, 8] ] ] ]
Print(D [1] [0] [0])

10. What will be the output of the following code segment?


list1 =[‘Red’, ‘Green’, ‘Blue’, ‘Cyan’, ‘Magenta’, ‘Yellow’, ‘Black’]
print(list1[-4 : 0 : -1])
11. Predict the output:
Let L1=[21,14,21,[24,25],21,”Welcome”]
I) Write a statement to print 24
II) What will be the output of the following statements?
A) print( L1 [-1] [-1] )
B) L1.insert(len( L1), “Kirthik”,)
print(L1)

12. Predict the output:


for i in ‘123’:
print(“Python”, i,)

13. X = “ Stay healthy”


print(x.find(‘h’, 2)
print(x. find ( ‘thy’, 2)

14. Write the output for the following:


Str=”Python#Language”
Print(str[2 : 12: 2] )
Print(str[: :-4] )
Print(str[-11 : -22]
Print(str[3 : 8 : -3])

15. Predict the output:


i)string = "one, two, three"
words = string.split(',')
print(words)

ii)word = 'CatBatSatFatOr'
print(word.split('t'))

iii)txt = "I could eat bananas all day"


x = txt.partition("bananas")
print(x)

iv) s = "Python is fun"


res = s.partition("Java")
print(res)

16. If a=(1,2,3), then (a,a,a) will be a __________


a)tuple b) Nested Tuple c) Error d)None

17. Amir plays a string game. He wants to display last four characters of string
object s. Which of the following statements are true?
a) s[4:] b) s[:4] c) s[-4:] d) s[:-4]

18. How can you add an element to a dictionary?


a)dict1.append(key, value) b)dict1[key]=value
c)dict1.add(key, value) d)dict1.insert(key, value)

19.What will be the output of the following code?


D1={‘a’ : 1, ‘b’ : 2}
D2={‘b’ : 3, ‘c’ : 4}
D1.update(D2)
print(D1)

20.Predict the output:


Places=[“Mumbai”, “Kolkata”, [“Kashmir”, [“Shimla”], “Chennai”, “Bangalore”]]
Place1=places[2][-1]
Place2=len(places[2][0])
print(Place1)
print(Place2)

You might also like