PyForSchool's Computer Science with Python Class XII 2023-24 [Revision Notes & Question Bank]
An outstanding 4.5 out of 5-star rating on Amazon!
Question 1.Find the invalid identifier from the following
Question 2. Which of the following is a function/method of the pickle module?
Question 3. For a given declaration in Python as S = "WELCOME". Which of the following will be the correct output of print(S [1: :2])?
Question 4. Which of the following statement is not correct?
Question 5. Which of the following option is the correct Python statement to read and display the first 10 characters of a text file "Notes.txt"?
Question 6. Which of the following is not a correct Python statement to open a text file "Notes.txt" to write content into it?
Question 7. A text file opened using the following statement : MyFile = open('Notes.txt') Which of the following is the correct Python statement to close it?
Question 8. Which of the following option is the correct usage for the tell( ) of a file objects?
Question 9. Which of the following is an incorrect Logical operator in Python?
Question 10. Given the Python declaration S1 = "Hello". Which of the following statement will give an error?
Question 11. Which of the following statement is incorrect in the context of pickled binary file?
Question 12. What is the significance of the seek() method?
Question 13. Which of the following is the correct expansion of csv?
Question 14. If the following statement is used to read the contents of a textfile object F:
X = F.readlines()
Which of the following is the correct data type of X?
Question 15. Which of the following is not correct in context of Positional and Default parameters in Python functions?
Question 16. For a function header as follows :
def Calc(X, Y=20):
Which of the following funtion calls will give an Error?
Question 17. Which of the following is not correct in context of scope of variables?
Question 18. Which of the following is the default character for the newline parameter for a csv file object opened in write mode in Python IDLE?
Question 19. Which of the following is the correct output for the execution of the following Python statement?
print(5 + 3 ** 2 / 2)
Question 20. Which of the following is not a Tuple in Python?
Question 21. Which of the following is not a funtion/method of the random module in Python?
Question 22. Which of the following is not a valid Python string operation?
Question 23. What will be the output for the following Python statements?
T = (10, 20, [30, 40, 50], 60, 70) T[2] [1] = 100 print(T)
Question 24. What will be the output for the following Python statements?
L = [10, 20, 30, 40, 50] L = L + 5 print(L)
Question 25. What will be the output for the following Python statements?
D = {"AMIT" : 90, "SUKHBIR" : 92, "JOHN" : 95} print("JOHN" in D, 90 in D, sep = "#")
Question 26. Nitish has declared a tuple T in Python as following :
T = (10 , 20 , 30)
Now , he wants to insert an element 40 after these three elements of T so that the tuple may contain (10 , 20 , 30 , 40)
Which of the following statement shall Nitish write to accomplish the above task?
Question 27. Suppose the content of a text file Notes.txt is :
"The way to get started is to quit talking and begin doing"
What will be the following Python code?
F = open("Notes.txt") F.seek(29) S = F.read() print(S)
Question 28. Identify the output of the following Python statements
S = "GOOD MORNING" print(S.capitalize(), S.title(), end = "!")
Question 29. Identify the output of the following Python statements
L = [] for i in range (4): L.append(2 * i + 1) print (L[::-1])
Question 30. Identify the output of the following Python statements:
D = {} T = ("ZEESHAN", "NISHANT", "GURMEET", "LISA") for i in range(1, 5): D[i] = T[i-1] print(D)
Question 31. Identify the output of the following statements
L1, L2 = [10, 15, 20, 25], [] for i in range (len(L1)): L2.insert(i, L1.pop()) print (L1, L2, sep="&")
Question 32. Which of the following Python modules is imported to store and retrieve objects using the process of serialization and deserialization?
Question 33. Which of the following function in used with the csv module in Python to read the contents of a csv file into an object?
Question 34. What will be the output of the following Python code?
S = "WELCOME" def Change(T): T = "HELLO" print(T, end = '@') Change(S) print(S)
Question 35. Identify the correct possible output for the following Python code :
import random for N in range (2, 5, 2): print(random.randrange(1,N), end="#")
Question 36. What will be the output of the following Python code?
def FunStr(S): T = "" for i in S: if i.isdigit(): T = T + i return T X = "PYTHON 3.9" Y = FunStr(X) print (X, Y, sep = "*")
Question 37. What will be the output of the following Python code?
V = 50 def Change(N): global V V, N = N, V print(V, N, sep="#", end="@") Change(20) print(V)
Question 38. Which of the following option can be the output for the following Python code?
L1 = [10, 20, 30, 20, 10] L2 = [] for i in L1: if i not in L2: L2.append(i) print(L1, L2, sep ="&")
Question 39. What is the output of the following Python code?
def ListChange(): for i in range(len(L)): if L[i] % 2 == 0: L[i] = L[i] * 2 if L[i] % 3 == 0: L[i] = L[i] * 3 else: L[i] = L[i] * 5 L = [2,6, 9, 10] ListChange() for i in L: print(i, end = "#")
Question 40. Suppose the content of a text file "Rhymes.txt" is as follows:
Jack & Jill
went up the hill
What will be the output of the following Python code?
F = open("Rhymes.txt") L = F.readlines() for i in L: S = i.split() print(len(S), end = "#")
Question 41. Identify the output of the following Python code
D = {1: "one", 2: "Two", 3: "Three"} L = [] for K, V in D.items (): if V [0] == "T": L.append(K) Print(L)
Question 42. Suppose the content of "Rhymes.txt" is:
Baa baa black sheep,
have you any wool?
What will be the output of the following Python code?
F = open ("Rhymes.txt") S = F.read() L = S.split() for i in L: if len(i) %3 != 0: print (i, end = " ")
Question 43. Suppose the content of "Rhymes.txt" is
One, two, three, four, five
Once I caught a fish alive.
What will be the output of the following Python code?
F = open ("Rhymes.txt") S = F.read() print(S.count ('e', 20))
Question 44. What will be the output of the following Python code?
V = 25 def Fun(ch): V = 50 print(V, end=ch) V *= 2 print(V, end=ch) print (V, end = "*") Fun ("!") print(V)
Question 45. Suppose the content of "Rhymes.txt" is
Good Morning Madam
What will be the output of the following Python code?
F = open("Rhymes.txt") L = F.read().split() for W in L: if W.lower() == W [::-1].lower(): print(W)
Question 46. Suppose the content of "Rhymes.txt" is
Hickory Dickory Dock
The mouse went up the clock
What will be the output of the following Python code?
F = open("Rhymes.txt") L = F.readlines() X = ["the", "ock"] for i in L: for W in i.split(): if W in X: print (W, end = "*")
Question 47. Consider the following directory structure
Suppose the present working directory is MyCompany. What will be the relative path of the file Transactions.Dat?
Question 48. What will be the output of the following Python code?
S = "UVW"; L = [10, 20, 30]; D = {} N=len(S) for I in range(N): D [L[I]] = S[I] for K, V in D.items(): print (K, V, sep="*", end=",")
Question 49. What will be the output of the following Python code?
L = [10, 20] L1 = [30, 40] L2 = [50, 60] L.append(L1) L.extend(L2) print(L)
Nisha, an intern in ABC Pvt, Ltd., is developing a project using the csv module in Python Nisha, an intern in ABC Pvt, Ltd., is developing a project using the csv module in Python. She has partially developed the code as follows leaving out statements about which she is not very confident. The code also contains errors in certain statements. Help her in completing the code to read the desired csv File named "Employee.csv"
CSV File contentIncomplete code with Errors
import CSV #statement-1 with open (____, ____, newline= ' ') as File: #statement-2 ER = csv.____ #statement-3 for R in range(ER): #statement-4 if ____ == "ACCOUNTS": #statement-5 print(____, ____) #statement-6
Question 50. Nisha gets an Error for the module name used in Statement-1. What should she write in place of CSV to import the correct module?
Question 51. identify the missing code for blank spaces in the line marked as statement-2 to open the mentioned file.
Question 52. Choose the function name (with parameter) that should be used in the line marked as statement-3
Question 53. Nisha gets an erroe in statement-4. What should she write to correct the statement?
Question 54. Identify the suitable code for blank space in Statement-5 to match every row's 3rd property with "ACCOUNTS".
Question 55. Identify the suitable code for blank space in statement-6 to display every Employee's name and corresponding Department?