Holiday worksheet class 12
Holiday worksheet class 12
COLLEGE
COMPUTER SCIENCE WORKSHEET
CLASS XII
8. (A)Write a Python function that displays all the words containing @cmail
from a text file "Emails.txt".
(B) Write a Python function that finds and displays all the words longer
than5 characters from a text file "Words.txt".
11. The code provided below is intended to swap the first and last elements of
a given tuple. However, there are syntax and logical errors in the code.
Rewrite it after removing all errors. Underline all the corrections made.
def swap_first_last(tup)
if len(tup) < 2:
return tup
new_tup = (tup[-1],) + tup[1:-1] + (tup[0])
return new_tup
result=swap_first_last(1,2,3,4)
print(“Swapped tuple:”, result)
12. What will be the output of the following Python code?
a=[10,23,56,[78,10]]
b=list(a)
a[3][0]+=17
print(b)
17. Assertion (A): CSV (Comma Separated Values) is a file format for data
storage that looks like a text file.
Reason (R): The information is organized with one record on each line and
each field is separated by a comma.
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A