2020-21 XII CS PT1
star
star
star
star
star
Last updated over 5 years ago
17 questions
Note from the author:
Questions As per cbse for class XII including chapter revision python, function and text file handling

1
Is Python a Compiler language or an interactive language?
Is Python a Compiler language or an interactive language?
1
Consider the code. What will be the output?b=12d=bIf id(b)==id(d):print(“Id are same”)else:print(“Id are not same”)
Consider the code. What will be the output?
b=12
d=b
If id(b)==id(d):
print(“Id are same”)
else:
print(“Id are not same”)
3
Find errors in the following code (if any) and correct the code by rewriting it and underlining the corrections:x=int(“Enter value of x”)for in range[0,11]:if x=yprint x+yElse:Print x-y
Find errors in the following code (if any) and correct the code by rewriting it and underlining the corrections:
x=int(“Enter value of x”)
for in range[0,11]:
if x=y
print x+y
Else:
Print x-y
3
Write the output of the following code when executed:Text=“KVina@com”Tl=len(Text)NewText=“”for i in range(0,Tl ):if Text[i].isupper():NewText=NewText+Text[i].lower()elif Text[i].isalpha():NewText=NewText+Text[i].upper()else:NewText=NewText+ “##”print(NewText)
Write the output of the following code when executed:
Text=“KVina@com”
Tl=len(Text)
NewText=“”
for i in range(0,Tl ):
if Text[i].isupper():
NewText=NewText+Text[i].lower()
elif Text[i].isalpha():
NewText=NewText+Text[i].upper()
else:
NewText=NewText+ “##”
print(NewText)
2
Write a python program to calculate the length of a string without using len() function.
Write a python program to calculate the length of a string without using len() function.
3
What is the difference between mutable and immutable data types?. Name them.
What is the difference between mutable and immutable data types?. Name them.
2
Write a python program to create a dictionary containing a book I’d and title taken from the user.
Write a python program to create a dictionary containing a book I’d and title taken from the user.

1
Python can have three types of functions: Name them.
Python can have three types of functions: Name them.
2
Write the forms to importing python module statements
Write the forms to importing python module statements
2
What is the difference between local variables and global variables? Also give suitable python code to illustrate both.
What is the difference between local variables and global variables? Also give suitable python code to illustrate both.
3
What is an argument? How many types of actual arguments? Write name also.
What is an argument? How many types of actual arguments? Write name also.
2
Write a python function to sum all the items/numbers in a list.
Write a python function to sum all the items/numbers in a list.
2
What are the different file processing mode supported by python?
What are the different file processing mode supported by python?
2
What is the difference between readline() and readlines() function?
What is the difference between readline() and readlines() function?
3
Write a function countword() in python to read the text file “abc.txt” and count the number of times “is” occurs in the file.
Write a function countword() in python to read the text file “abc.txt” and count the number of times “is” occurs in the file.
3
Write a method in python to read lines from a text file “xyz.txt” and display those lines which start with the alphabet “H”
Write a method in python to read lines from a text file “xyz.txt” and display those lines which start with the alphabet “H”
5
a) A ___________ function links the file object with the file on the disk.b) A ___________ function breaks the link of the file object and the file on the disk.c) A ___________ function read all lines and stores in the list.d) A ___________ function is used to convert a sentence string into word list.e) A ___________ function is used to write a list in a text file.
a) A ___________ function links the file object with the file on the disk.
b) A ___________ function breaks the link of the file object and the file on the disk.
c) A ___________ function read all lines and stores in the list.
d) A ___________ function is used to convert a sentence string into word list.
e) A ___________ function is used to write a list in a text file.