CBSE Class 12 · Computer Science (083) · Python
Find out how ready you are: get an instant score and a unit-by-unit report showing what to revise. These are PyRun practice marks, not CBSE's marking scheme.
21 marks · Section A 8 × 1 · Section B 4 × 1 · Section C 3 × 3. Your answers are saved in this browser as you type. Attempted 0/15.
Type exactly what the program prints, one printed line per line. Extra spaces don't matter; capitals, quotes and brackets do.
s = "Examination" print(s[2:7], s[-4:-1], len(s[::3]))
L = [4, 8, 15, 16, 23] print(L[::-2], L[1:-1], 15 in L)
a, b = 7, 3 print(a // b, a % b, a ** b // 10, -a // b)
D = {"x": 3, "y": 5}
D.update({"y": 1, "z": 9})
print(sorted(D.values()), list(D)[-1])
def f(x, y=2):
return x * y + y
print(f(3), f(3, 4), f(y=1, x=5))
total = 10
def add(n):
total = n + 5
return total
print(add(3), total)
try:
print("A")
x = [1, 2][2]
print("B")
except IndexError:
print("C")
finally:
print("D")
st = [5, 9] st.append(2) st.append(st.pop() + st.pop()) print(st, len(st))
Each program stops with an error. Pick the one Python raises.
n = "5" print(n + 2)
marks = [90, 80] print(marks[2])
def area(r):
return 3.14 * r * r
print(Area(2))
age = int("twenty")
Write the function, then press Check: it runs your code on hidden tests right here in the browser (files are created for you). You can check as often as you like before submitting.
Write a function count_start(filename, ch) that returns how many lines of the text file start with the letter ch (exact case).
Write push_even(nums, stack) that pushes every even number of the list nums onto stack (a list), and pop_item(stack) that pops and returns the top item, or returns the string "Underflow" when the stack is empty.
Write word_freq(sentence) that returns a dictionary mapping each word (split on spaces, compared in lowercase) to how many times it appears.