WorksheetsFinal Python Quiz 2023
Total questions: 20
Worksheet time: 10mins
Why is it necessary to import the "random" module?
It adds random numbers to the code
It helps us generate random words
It provides a random color for the text
It creates random graphics
What is the purpose of the "get_word" function in the project?
It generates a random word
It displays the story
It asks the user for words like nouns and verbs
It prints "Hello, World!"
In the "generate_story" function, what is the role of "nouns" and "adjectives"?
They are used for mathematical calculations
They are used to print messages to the console
They describe the characters and objects in the story
They represent programming concepts
What does the loop in the project do?
It generates random numbers
It asks the user for their name
It allows the user to keep making stories
It performs a mathematical calculation
In Python, how do you define a function called "my_function" that takes two parameters, "param1" and "param2"?
function my_function(param1, param2)
define my_function(param1, param2):
def my_function(param1, param2):
def my_function(param1 param2)
In the "generate_story" function, what is the purpose of the following line of code?
It prints the story to the console.
It defines the "generate_story" function.
It puts together the story using user-input words.
It generates random words for the story.
What is the purpose of the while loop in the project?
It generates random numbers.
It asks the user for their name.
It allows the user to keep making stories.
It performs a mathematical calculation.
In Python, how do you prompt the user to input a value and store it in a variable named "user_input"?
input user_input = "Enter a value: "
user_input = input("Enter a value: ")
user_input("Enter a value: ")
prompt("Enter a value: ")
What is the purpose of the "break" statement in the while loop in the project?
It generates words.
It asks the user for their name.
It allows the user to keep making stories.
It exits the loop and stops making stories. random
When using functions in Python, what is the benefit of passing parameters?
Parameters are not required in Python functions.
Parameters allow you to define a function's name.
Parameters help the function accept inputs and process them.
Parameters determine the return value of a function.
What does the following line of code do in Python?
It defines a new variable called "adjectives."
It generates a random adjective.
It calls the "get_word" function and asks the user for an adjective.
It prints "adjective" to the console.
How would you define a list called "fruits" containing the elements "apple," "banana," and "orange" in Python?
list fruits = ["apple", "banana", "orange"]
fruits = list("apple", "banana", "orange")
fruits = ["apple", "banana", "orange"]
define fruits = ["apple", "banana", "orange"]
In Python, what is the purpose of the "print" statement?
It defines a new function.
It imports external modules.
It prompts the user for input.
It displays information or outputs to the console.
What is the purpose of importing the "random" module in the code?
a) It allows the user to input random words
b) It helps generate random elements, like picking words in different orders for the story
c) It improves the performance of the code
d) It adds color to the output
Which word type is used to describe nouns?
a) Adverbs
b) Pronouns
c) Verbs
d) Adjectives
Which word type is used to describe verbs?
a) Adjectives
b) Pronouns
c) Nouns
d) Adverbs
Which word type is used to replace nouns to avoid repetition?
a) Adverbs
b) Pronouns
c) Prepositions
d) Conjunctions
Which word type is used to express strong emotions or feelings?
a) Adverbs
b) Pronouns
c) Interjections
d) Conjunctions
What is the purpose of the loop in the code?
a) It allows the user to generate infinite stories
b) It repeats the story generation process multiple times
c) It adds randomness to the stories
d) It improves the performance of the code
What does the loop do if the user wants to generate another story?
a) Asks the user to input another story
b) Terminates the program
c) Calls the "generate_story" function to create a new story
d) Prints the previously generated story again
