Question: !Sys.argv and NO input function. Please do not copy other answers! Assume you were given the following data about customer visits to a grocery store.

!Sys.argv and NO input function. Please do not copy other answers!

Assume you were given the following data about customer visits to a grocery store. After the customer's name, the 3 inputs are the number of visits to the store per month. The data is provided at runtime as sys.argv.

2Kris 4 5 3

Jo-Marie 6 5 5

Gabe 2 2 2

Here is what you can assume I will type in command prompt:

python test1-4.py Kris 4 5 3

python test1-4.py Jo-Marie 6 cat 5

python test1-4.py Gabe 2 2 2

Write a script called test1-4.py that does the following:

Calculate the average visits per month (4 for Kris) as a parameter and returns a message according to the frequency of visits. The average number of visits may be a decimal.

When the average is at least 4, the shopper is labeled a super shopper.

Uses try/except to ensure that the second, third, and fourth parameters (4, 5, 3 for Kris) passed at runtime is actually a number.

The output for the above input should exactly match the following:

Kris shops on average 4 times per month and is a super shopper.

Invalid data.

Gabe shops on average 2 times per month.

The output for running this with 'cat' instead of a number should exactly match the following:

Invalid data.

Change the "Invalid data" message indicate which parameter is not valid. For example, with the following input ipython test1-4.py Jo-Marie 6 cat 5 no

the output would be "Number of visits for second month is invalid".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!