Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Final Python Quiz 2023

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Why is it necessary to import the "random" module?

a)
  • It adds random numbers to the code

b)
  • It helps us generate random words

c)
  • It provides a random color for the text

d)
  • It creates random graphics

2.

What is the purpose of the "get_word" function in the project?


a)
  • It generates a random word

b)
  • It displays the story

c)
  • It asks the user for words like nouns and verbs

d)
  • It prints "Hello, World!"

3.

In the "generate_story" function, what is the role of "nouns" and "adjectives"?

a)
  • They are used for mathematical calculations

b)
  • They are used to print messages to the console

c)
  • They describe the characters and objects in the story

d)
  • They represent programming concepts

4.

What does the loop in the project do?

a)
  • It generates random numbers

b)
  • It asks the user for their name

c)
  • It allows the user to keep making stories

d)
  • It performs a mathematical calculation

5.

In Python, how do you define a function called "my_function" that takes two parameters, "param1" and "param2"?

a)
  • function my_function(param1, param2)

b)
  • define my_function(param1, param2):

c)

def my_function(param1, param2):

d)
  • def my_function(param1 param2)

6.

In the "generate_story" function, what is the purpose of the following line of code?

a)
  • It prints the story to the console.


b)
  • It defines the "generate_story" function.

c)
  • It puts together the story using user-input words.

d)
  • It generates random words for the story.

7.
  1. What is the purpose of the while loop in the project?

a)
  • It generates random numbers.

b)
  • It asks the user for their name.

c)
  • It allows the user to keep making stories.

d)
  • It performs a mathematical calculation.

8.

In Python, how do you prompt the user to input a value and store it in a variable named "user_input"?

a)
  • input user_input = "Enter a value: "

b)
  • user_input = input("Enter a value: ")

c)
  • user_input("Enter a value: ")

d)
  • prompt("Enter a value: ")

9.

What is the purpose of the "break" statement in the while loop in the project?

a)
  • It generates words.

b)
  • It asks the user for their name.

c)
  • It allows the user to keep making stories.

d)
  • It exits the loop and stops making stories. random

10.

When using functions in Python, what is the benefit of passing parameters?

a)
  • Parameters are not required in Python functions.

b)
  • Parameters allow you to define a function's name.

c)
  • Parameters help the function accept inputs and process them.

d)
  • Parameters determine the return value of a function.

11.

What does the following line of code do in Python?


a)
  • It defines a new variable called "adjectives."

b)
  • It generates a random adjective.

c)
  • It calls the "get_word" function and asks the user for an adjective.

d)
  • It prints "adjective" to the console.

12.

How would you define a list called "fruits" containing the elements "apple," "banana," and "orange" in Python?

a)
  • list fruits = ["apple", "banana", "orange"]

b)
  • fruits = list("apple", "banana", "orange")

c)
  • fruits = ["apple", "banana", "orange"]

d)
  • define fruits = ["apple", "banana", "orange"]

13.

In Python, what is the purpose of the "print" statement?


a)
  • It defines a new function.

b)
  • It imports external modules.

c)
  • It prompts the user for input.

d)
  • It displays information or outputs to the console.

14.

What is the purpose of importing the "random" module in the code?

a)

a) It allows the user to input random words

b)

b) It helps generate random elements, like picking words in different orders for the story

c)

c) It improves the performance of the code

d)

d) It adds color to the output

15.

Which word type is used to describe nouns?

a)
  1. a) Adverbs

b)
  1. b) Pronouns

c)
  1. c) Verbs

d)
  1. d) Adjectives

16.

Which word type is used to describe verbs?

a)

a) Adjectives

b)

b) Pronouns

c)

c) Nouns

d)

d) Adverbs

17.

Which word type is used to replace nouns to avoid repetition?

a)

a) Adverbs

b)

b) Pronouns

c)

c) Prepositions

d)

d) Conjunctions

18.

Which word type is used to express strong emotions or feelings?

a)
  1. a) Adverbs


b)
  1. b) Pronouns

c)
  1. c) Interjections

d)
  1. d) Conjunctions

19.

What is the purpose of the loop in the code?

a)

a) It allows the user to generate infinite stories

b)

b) It repeats the story generation process multiple times

c)

c) It adds randomness to the stories

d)

d) It improves the performance of the code

20.

What does the loop do if the user wants to generate another story?

a)

a) Asks the user to input another story

b)

b) Terminates the program

c)

c) Calls the "generate_story" function to create a new story

d)

d) Prints the previously generated story again