Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Module 2 Required Coding Activity Introduction to Python ( Unit 2 ) Fundamentals Be sure to complete all tutorials and practice prior to attempting this
Module Required Coding Activity
Introduction to Python Unit Fundamentals
Be sure to complete all tutorials and practice prior to attempting this activity.
Important Assignment Requirements
NOTE: This program requires creating a function using def and return, using print output, input, if in keywords, appendpopremove list methods. Be sure to include your full name in the prompts. See the example input below for more detail.
Program: listomatic
This program takes string input and checks if that string is in a list of strings
if string is in the list it removes the first instance from list
if string is not in the list the input gets appended to the list
if the string is empty then the last item is popped from the list
if the list becomes empty the program ends
if the user enters "quit" then the program ends
program has parts
program flow which can be modified to ask for a specific type of item. This is the programmers choice. Add a list of fish, trees, books, movies, songs.... your choice.
listomatic Function which takes arguments of a string and a list. The function modifies the list and returns a message as seen below.
Flowchart of ListoMatic
initialize a list with several strings at the beginning of the program flow and follow the flow chart and output examples
example inputoutput
Welcome, YOUR NAME GOES HERE Look at all the animals cat 'goat', 'cat'
enter the name of an animal: horse
instance of horse appended to list
Welcome, YOUR NAME GOES HERE Look at all the animals cat 'goat', 'cat', 'horse'
enter the name of an animal: cat
instance of cat removed from list
Welcome, YOUR NAME GOES HERE Look at all the animals goat 'cat', 'horse'
enter the name of an animal: cat
instance of cat removed from list
Welcome, YOUR NAME GOES HERE Look at all the animals goat 'horse'
enter the name of an animal: entered empty string
horse popped from list
Welcome, YOUR NAME GOES HERE Look at all the animals goat
enter the name of an animal: entered empty string
goat popped from list
Goodbye!
example
Welcome, YOUR NAME GOES HERE Look at all the animals cat 'goat', 'cat'
enter the name of an animal: Quit
Goodbye!
from
# create listomatic as a function and call it
# be sure to include your spelledout name in the welcome prompt
# you are welcome to use any list you like for listomatic, does not have to be animals
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started