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

  1. Q1Multiple choice1 mark
    What is the output of the following code? t = 'Computer' print(t[-3:])
    1. (a)uter
    2. (b)omp
    3. (c)mpute
    4. (d)ter
    Show answer and step marks
    1. Correct option: (d) ter+1
    Answer: (d)
  2. Q2Multiple choice1 mark
    Consider the dictionary d={d = \{'pen': 5, 'pencil': 8}\}. Why does dd['eraser'] raise an error, while dd.get('eraser') does not?
    1. (a)The key 'eraser' does not exist, so indexing raises KeyError, whereas get() returns None for a missing key.
    2. (b)get() raises an error for a missing key, whereas indexing returns None for it.
    3. (c)Dictionary keys must be integers, so the string 'eraser' is not allowed for indexing.
    4. (d)print() skips missing keys, so get() displays nothing while indexing displays an error.
    Show answer and step marks
    1. Correct option: (a) The key 'eraser' does not exist, so indexing raises KeyError, whereas get() returns None for a missing key.+1
    Answer: (a)
  3. Q3Assertion and reason1 mark
    Assertion (A): The elements of a list can be changed in place after the list is created. Reason (R): Lists are immutable objects in Python.
    1. (a)Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
    2. (b)Both Assertion (A) and Reason (R) are true but Reason (R) is not the correct explanation of Assertion (A).
    3. (c)Assertion (A) is true but Reason (R) is false.
    4. (d)Assertion (A) is false but Reason (R) is true.
    Show answer and step marks
    1. Correct option: (c) Assertion (A) is true but Reason (R) is false.+1
    Answer: (c)
  4. Q4Assertion and reason1 mark
    Assertion (A): The keys of a dictionary must be unique. Reason (R): A dictionary values can be lists or other containers.
    1. (a)Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
    2. (b)Both Assertion (A) and Reason (R) are true but Reason (R) is not the correct explanation of Assertion (A).
    3. (c)Assertion (A) is true but Reason (R) is false.
    4. (d)Assertion (A) is false but Reason (R) is true.
    Show answer and step marks
    1. 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)
  5. Q5Short answer2 marks
    Which one of the following names is a valid Python identifier: 'Total_Marks', '2ndRank', 'for', 'pass-mark'? Give a reason.
    Show answer and step marks
    1. Valid identifier: Total_Marks+1
    2. 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
  6. Q6Long answer5 marks
    Riya 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
    1. (a) Exponent is evaluated first: y∗∗z=125y ** z = 125; then x//y=9x // y = 9 and x%125=47x \% 125 = 47, so the value is 9+47=569 + 47 = 56.+1
    2. (b) Comparisons first: x>40x > 40 is True, y∗∗z<100y ** z < 100 is False, x%2!=0x \% 2 != 0 is True; then (True and False) or True(\text{True and False}) \text{ or True} gives True.+1
    3. (c) Amount =price×qty×(100−discount)/100= \text{price} \times \text{qty} \times (100 - \text{discount}) / 100, e.g. price × qty × (100 - discount) / 100 (or price × qty - price × qty × discount / 100).+1
    4. (d) s[1:4]=s[1:4] = "YTH"; ×2\times 2 gives "YTHYTH"; s[−1]=s[-1] = "N"; concatenated value is "YTHYTHN".+1
    5. (e) 5∗∗2=255 ** 2 = 25 is evaluated first, so 12//25=012 // 25 = 0; qty/5=2.4qty / 5 = 2.4; the value is 2.4+0=2.42.4 + 0 = 2.4.+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
See a sample marked answer sheet

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

More Class 12 Computer Science mock tests