
CBSE Class 12 Python Quiz
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Medium
dcsgs sdfdg
Used 10+ times
FREE Resource
Enhance your content in a minute
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code def func(a, b=5): return a * b print(func(3))
15
8
Error
None
Answer explanation
The function 'func' takes two parameters, 'a' and 'b' (default is 5). When calling 'func(3)', 'a' is 3 and 'b' defaults to 5. Thus, it calculates 3 * 5, which equals 15. Therefore, the correct answer is 15.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code x = 10 def func(): x = 5 print(x) func() print(x)
5, 10
10, 5
5, 5
10, 10
Answer explanation
In the function 'func()', the local variable 'x' is set to 5, so 'print(x)' inside the function outputs 5. The global 'x' remains 10, so 'print(x)' outside the function outputs 10. Thus, the output is 5, 10.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code try: print(10 / 0) except ZeroDivisionError: print("Error") finally: print("Done")
Error
Error, Done
Done
None
Answer explanation
The code attempts to divide by zero, raising a ZeroDivisionError, which is caught by the except block that prints 'Error'. The finally block executes next, printing 'Done'. Thus, the output is 'Error, Done'.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code try: num = int("abc") except ValueError: print("Invalid") else: print("Valid")
Invalid
Valid
Error
None
Answer explanation
The code attempts to convert the string 'abc' to an integer, which raises a ValueError. The except block catches this error and prints 'Invalid', so the correct answer is 'Invalid'.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code with open("test.txt", "w") as file: file.write("Hello World") with open("test.txt", "r") as file: print(file.read())
Hello World
Error
None
Blank
Answer explanation
The code writes 'Hello World' to 'test.txt' and then reads it back. Since the write operation is successful, the output of the read operation is 'Hello World', making it the correct answer.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code with open("test.txt", "a") as file: file.write(" Python code") with open("test.txt", "r") as file: print(file.read())
Hello World Python code
Python code
Error
None
Answer explanation
The code appends ' Python code' to 'test.txt'. If 'test.txt' initially contains 'Hello World', the final content will be 'Hello World Python code'. Thus, the correct answer is 'Hello World Python code'.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Python code import pickle data = {"name": "Alice", "age": 25} with open("data.dat", "wb") as file: pickle.dump(data, file) with open("data.dat", "rb") as file: print(pickle.load(file))
{"name": "Alice", "age": 25}
Error
None
Blank
Answer explanation
The code uses pickle to serialize a dictionary and save it to a file. It then reads the file and deserializes the data back into a dictionary. The output is the original dictionary: {'name': 'Alice', 'age': 25}.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Quiz ASJ
Quiz
•
12th Grade
20 questions
HISTORY OF COMPUTER_SUMMATIVE 1
Quiz
•
11th - 12th Grade
20 questions
TIK 9 - Penggunaan Browser Untuk Akses Internet
Quiz
•
11th - 12th Grade
17 questions
Quiz 01 Keamanan Jaringan
Quiz
•
12th Grade
20 questions
Ulangan Harian 1 CSS PPL 2
Quiz
•
9th - 12th Grade
15 questions
Operating System Components
Quiz
•
12th Grade
20 questions
Quiz
•
7th - 12th Grade
20 questions
Format File Gambar
Quiz
•
12th Grade
Popular Resources on Wayground
8 questions
2 Step Word Problems
Quiz
•
KG - University
20 questions
Comparing Fractions
Quiz
•
4th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Latin Bases claus(clois,clos, clud, clus) and ped
Quiz
•
6th - 8th Grade
22 questions
fractions
Quiz
•
3rd Grade
7 questions
The Story of Books
Quiz
•
6th - 8th Grade
Discover more resources for Computers
8 questions
2 Step Word Problems
Quiz
•
KG - University
10 questions
Martin Luther King, Jr. For Kids
Interactive video
•
1st - 12th Grade
10 questions
Dr. King's Speech and Its Impact
Interactive video
•
7th - 12th Grade
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
7 questions
Anti-Bullying ARS 15-341
Quiz
•
9th - 12th Grade
13 questions
Model Exponential Growth and Decay Scenarios
Quiz
•
9th - 12th Grade
15 questions
TSI Math Practice Questions
Quiz
•
8th - 12th Grade
24 questions
Identify Properties of Polygons and Quadrilaterals
Quiz
•
9th - 12th Grade
