Write a program called p2.py that contains a function called word_selection () that takes a list as a parameter and randomly selects one item in the list and prints it. Your program should have the following functionality: 1. Continuously prompt the user to enter a word until the user enters q 2. Store the entered words in a list 3. Making use of the random module, your program should call word_selection() that randomly selects a word from the list and prints it 4. Include the guard for the main function: if name main main() Example:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question
100%
Problem 2
Write a program called p2.py that contains a function called word selection () that takes a
list as a parameter and randomly selects one item in the list and prints it. Your program should
have the following functionality:
1. Continuously prompt the user to enter a word until the user enters q
2. Store the entered words in a list
3. Making use of the random module, your program should call word selection () that
randomly selects a word from the list and prints it
4. Include the guard for the main function:
if
name
main
':
==
main()
Example:
Enter a word (or 'q' to quit): Wallaby
to quit): Dingo
Enter a word (or 'q'
Enter a word (or 'q' to quit): Platypus
Enter a word (or 'q' to quit): q
Wallaby
Transcribed Image Text:Problem 2 Write a program called p2.py that contains a function called word selection () that takes a list as a parameter and randomly selects one item in the list and prints it. Your program should have the following functionality: 1. Continuously prompt the user to enter a word until the user enters q 2. Store the entered words in a list 3. Making use of the random module, your program should call word selection () that randomly selects a word from the list and prints it 4. Include the guard for the main function: if name main ': == main() Example: Enter a word (or 'q' to quit): Wallaby to quit): Dingo Enter a word (or 'q' Enter a word (or 'q' to quit): Platypus Enter a word (or 'q' to quit): q Wallaby
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning