Worksheets › Class 12 › Functions

Class 12 · Computer Science worksheet

Functions

CBSE Computer Science. Built-in, module and user-defined functions, default and keyword arguments, returning values, flow of execution, local and global scope. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.

Open a printable sample sheet

Sample questions

Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.

Section A · multiple choice

  1. 1.

    The values written in a function call are called:

    1. return values
    2. local variables
    3. parameters
    4. arguments
    Answer

    (d) arguments

  2. 2.

    What does this print? def area(l, b=5):     return l * b + 9 print(area(8), area(8, 9))

    1. 49 54
    2. 17 81
    3. 50 81
    4. 49 81
    Answer

    (d) 49 81

    b takes its default value only when it is not passed

  3. 3.

    What does this print? def total(p, q=2, r=5):     return p + q * r print(total(1, 9))

    1. 46
    2. 15
    3. 11
    4. 64
    Answer

    (a) 46

    match keyword arguments by name, the rest by position; missing ones take their defaults

Section B · short answer

  1. 4.

    What is the difference between a parameter and an argument?

    Answer

    A parameter is the name in the function header; an argument is the value passed in the function call.

  2. 5.

    What does this print? Give (a) the first value (b) the second. def area(l, b=9):     return l * b + 9 print(area(6), area(6, 8))

    Answer

    (a) 63; (b) 57

    b takes its default value only when it is not passed

Section C · long answer

  1. 6.

    Explain with an example how default and keyword arguments work, and the rules for using them.

    Answer

    def f(a, b=2, c=3): return a + b * c. f(1) = 7, f(1, 4) = 13, f(1, c=5) = 11, f(c=5, a=1) = 11. Default parameters must come after the others in the header; in a call, keyword arguments come after positional ones and no parameter may get two values.

Fresh sheets for your child

In the app, every Functions sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.

Coming soon for Android and iPhone.

More Class 12 Computer Science