CBSE · Class 12 · Computer Science
Class 12 Python Revision Tour Mock Test (CBSE)
6 practice questions from Python Revision Tour, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.
Topics in Python Revision Tour
- Tokens, variables and data types
- Operators and expressions
- Flow of control
- Strings
- Lists
- Tuples
- Dictionaries
- Mutable and immutable types
Python Revision Tour practice questions with answers
- Q1Multiple choice1 markWhat is the output of the following code? t = 'Computer' print(t[-3:])
- (a)uter
- (b)omp
- (c)mpute
- (d)ter
Show answer and step marks
- Correct option: (d) ter+1
Answer: (d) - Q2Multiple choice1 markConsider the dictionary 'pen': 5, 'pencil': 8. Why does ['eraser'] raise an error, while .get('eraser') does not?
- (a)The key 'eraser' does not exist, so indexing raises KeyError, whereas get() returns None for a missing key.
- (b)get() raises an error for a missing key, whereas indexing returns None for it.
- (c)Dictionary keys must be integers, so the string 'eraser' is not allowed for indexing.
- (d)print() skips missing keys, so get() displays nothing while indexing displays an error.
Show answer and step marks
- Correct option: (a) The key 'eraser' does not exist, so indexing raises KeyError, whereas get() returns None for a missing key.+1
Answer: (a) - Q3Assertion and reason1 markAssertion (A): The elements of a list can be changed in place after the list is created. Reason (R): Lists are immutable objects in Python.
- (a)Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
- (b)Both Assertion (A) and Reason (R) are true but Reason (R) is not the correct explanation of Assertion (A).
- (c)Assertion (A) is true but Reason (R) is false.
- (d)Assertion (A) is false but Reason (R) is true.
Show answer and step marks
- Correct option: (c) Assertion (A) is true but Reason (R) is false.+1
Answer: (c) - Q4Assertion and reason1 markAssertion (A): The keys of a dictionary must be unique. Reason (R): A dictionary values can be lists or other containers.
- (a)Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
- (b)Both Assertion (A) and Reason (R) are true but Reason (R) is not the correct explanation of Assertion (A).
- (c)Assertion (A) is true but Reason (R) is false.
- (d)Assertion (A) is false but Reason (R) is true.
Show answer and step marks
- Correct option: (b) Both Assertion (A) and Reason (R) are true but Reason (R) is not the correct explanation of Assertion (A).+1
Answer: (b) - Q5Short answer2 marksWhich one of the following names is a valid Python identifier: 'Total_Marks', '2ndRank', 'for', 'pass-mark'? Give a reason.
Show answer and step marks
- Valid identifier: Total_Marks+1
- Reason: '2ndRank' starts with a digit, 'for' is a keyword, and 'pass-mark' contains a hyphen, so each breaks a naming rule+1
Answer: Total_Marks - Q6Long answer5 marksRiya has assigned the following variables in the Python shell: x = 47, y = 5, z = 3, price = 45, qty = 12, discount = 15 and s = "PYTHON". Answer the parts below. (a) State the value of the expression x // y + x % y ** z. [1] (b) State the value of the expression x > 40 and y ** z < 100 or x % 2 ≠ 0. [1] (c) Write one Python expression that gives the amount payable for qty notebooks at price per notebook after the percentage discount is applied. [1] (d) State the value of the expression s[1:4] × 2 + s[-1]. [1] (e) State the value of the expression qty / 5 + qty // 5 ** 2. [1]
Show answer and step marks
- (a) Exponent is evaluated first: ; then and , so the value is .+1
- (b) Comparisons first: is True, is False, is True; then gives True.+1
- (c) Amount , e.g. price × qty × (100 - discount) / 100 (or price × qty - price × qty × discount / 100).+1
- (d) "YTH"; gives "YTHYTH"; "N"; concatenated value is "YTHYTHN".+1
- (e) is evaluated first, so ; ; the value is .+1
Answer: (a) 56; (b) True; (c) price × qty × (100 - discount) / 100, which gives 459.0; (d) "YTHYTHN"; (e) 2.4
Take a full Python Revision Tour test
PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.
- 15 min10 marks
- 30 min20 marks
- 1.5 hr40 marks
- 3 hr80 marks
Get your Python Revision Tour answers marked
Sign in, pick this chapter and a length, write the test on paper and get every step marked.
Sign in to take this test