placeholder image to represent content

Functions

Quiz by Kevin Moore

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
10 questions
Show answers
  • Q1

    Functions can do all of the following except:

    Ask the user for input

    Allow writing without proper syntax

    Stop the program from repeating

    Simplify code

    30s
  • Q2

    In Python, you define the __________ first, then call it underneath

    return

    main program

    Print statement

    subprogram

    30s
  • Q3

    What is output by the following program?

    def test():

         print("Rainbow")

    #MAIN

    test()

    print("Sunshine")

    print("Storm.")

    print(“Rainbow”) Sunshine Storm

    Rainbow Sunshine Storm

    Storm. Sunshine Rainbow

    Sunshine Storm. Rainbow

    30s
  • Q4

    Which of the following parameters is optional?

    sample(a, b, c, d=9)

    d

    b

    c

    a

    30s
  • Q5

    What is output by the following program?

    def mult(a, b = 1, c = 1):

         return(a * b * c)

    print(mult(2, 5, 8))

    80

    0

    10

    2

    30s
  • Q6

    What is output by the following program?

    def sample(val):

         val = val * 10

    #MAIN

    n = 4

    sample(n)

    print(n)

    None of the above.  The code has an error - it is missing a parameter.

    40

    4

    1

    30s
  • Q7

    What is output by the following code?

    def mystery(w):

         if (w == w.upper()):

              return "TRUE"

         else:

               return "FALSE"

    print(mystery("What a wonderful day!"))

    FALSE

    TRUE

    "What a wonderful day!"

    What a wonderful day!

    30s
  • Q8

    Consider the following program:

    def sillyString(w):

         return w.replace( "a", "oo")

    #MAIN

    fruit = input ("Enter a state: ")

         print(sillyString(fruit))

    What is the output if the user enters “california”?

    california

    None of the above.  The code has an error.

    coolifornioo

    coo

    30s
  • Q9

    Functions are mainly used to ________________________.

    input data into a program

    represent numeric data

    write output to the screen

    organize longer programs

    30s
  • Q10

    What is output by the following program?

    def greeting(name):

    print("Hello ", name.upper())

    greeting("Bobby")

    HELLO Bobby

    None of the above.  The code has an error.

    Hello bobby

    Hello Bobby

    30s

Teachers give this quiz to your class