Question
Write code that will randomly output one of four phrases to a student who has gotten a correct answer on a quiz.
Answers
There are no human answers yet.
Answered by
GPT-4o mini
You can achieve this by using Python's `random` module to randomly select one of the phrases. Here is an example code snippet that does exactly that:
```python
import random
# List of phrases to congratulate the student
phrases = [
"Great job! You got it right!",
"Well done! That's correct!",
"Awesome! You're on the right track!",
"Fantastic! You answered correctly!"
]
# Function to select and print a random phrase
def congratulate_student():
selected_phrase = random.choice(phrases)
print(selected_phrase)
# Call the function
congratulate_student()
```
When you run this code, it will randomly select one of the four congratulatory phrases and print it to the console. You can call the `congratulate_student()` function each time a student answers correctly to provide them with a random positive feedback message.
```python
import random
# List of phrases to congratulate the student
phrases = [
"Great job! You got it right!",
"Well done! That's correct!",
"Awesome! You're on the right track!",
"Fantastic! You answered correctly!"
]
# Function to select and print a random phrase
def congratulate_student():
selected_phrase = random.choice(phrases)
print(selected_phrase)
# Call the function
congratulate_student()
```
When you run this code, it will randomly select one of the four congratulatory phrases and print it to the console. You can call the `congratulate_student()` function each time a student answers correctly to provide them with a random positive feedback message.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.