Answered step by step
Verified Expert Solution
Link Copied!

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 2 Required Coding Activity
Introduction to Python (Unit 2) 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, .append(),.pop(),.remove() list methods. Be sure to include your full name in the prompts. See the example input below for more detail.
Program: list-o-matic
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 2 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.
list-o-matic Function which takes arguments of a string and a list. The function modifies the list and returns a message as seen below.
Flowchart of List-o-Matic
[] initialize a list with several strings at the beginning of the program flow and follow the flow chart and output examples
example input/output
Welcome, [YOUR NAME GOES HERE]. Look at all the animals ['cat', 'goat', 'cat']
enter the name of an animal: horse
1 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
1 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
1 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 2
Welcome, [YOUR NAME GOES HERE]. Look at all the animals ['cat', 'goat', 'cat']
enter the name of an animal: Quit
Goodbye!
from
# [] create list-o-matic as a function and call it
# [] be sure to include your spelled-out name in the welcome prompt
# [] you are welcome to use any list you like for list-o-matic, does not have to be animals

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Discuss communication challenges in a global environment.

Answered: 1 week ago