Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: code First, you will submit code for the challenge below. You willnotsubmit this through codepost. Instead, you will run your code throughthis online

Part 1: code

First, you will submit code for the challenge below. You willnotsubmit this through codepost. Instead, you will run your code throughthis online PEP-8 checker(Links to an external site.)and fix all of the errors. When the results of the check list no errors (like this(Links to an external site.)) you can submit your code. Save your script asmodule-03-challenge.py- submit only the version of your script after making the PEP8-recommended changes.

Part 2: Review my code

After the deadline for part 1 has passed I will post an answer to the challenge. Part 2 is about this question:Which is better, my code or yours?This is not a competition of course, but the idea here is to look at two coding solutions to the same problem and identify what might be better about one that the other should consider doing. So, for the second part of the assignment you will fix your code or mine, or maybe a bit of both!

  1. Create a second copy of your script namedmodule-03-challenge-updated.py.
  2. Review my code and compare it to yours.
  3. Update your code with anything you see in my code that should be incorporated into yours. I.e., Fix your code according to what is in my code.
  4. If you have done something in your code that you think should be changed inmycode, keep your code the same and add comments that explain what is "better" about your code compared to mine.

NB: Just because I do something differently in my solution does not necessarily mean it's better. There are no tricks in my code - what you see is my genuine attempt at solving the challenge with only what we have covered in class thus far.

How to submit your code

This assignment is set up to accept two "attempts" but you will submit your code like this:

  1. Attempt 1 is yourmodule-03-challenge.pyscript from part 1.This is due by the posted deadline.
  2. Attempt 2 is yourmodule-03-challenge-updated.pyupdated script from part 2. A new deadline will be posted after the deadline for attempt 1 has passed.

The coding challenge

Using only material that we have covered in the class so far, including functions or methods that are part of the PSL. write a functioning Python script based on this scenario and starter code below.

Scenario:We manage a mailing list for the local pet shop. In this scenario, we have data about customers who have and have not subscribed to our email announcements. Using the data object below, write a script that:

  1. Displays on the screen a report of how many of the customers are subscribed.
  2. Displays on the screen a report of people to offer a special deal to in order to get them to subscribe.

A few tips to get you started, if you need them:

  1. Think about what actions you need to do and identify the functions and methods necessary to do those actions.
  2. Think about the logic of the action(s) - are you making a decision? Iterating over a sequence? Something else, or a mix of these actions?
  3. Remember that code is read more often than it is executed, and that will always be factored into your grade.
  4. Finally, remember thatfailing code is failing code.

Carefullycopy and paste this code into VS Code and add your code to the bottom.

data = [{ "id": 1, "first_name": "Townsend", "last_name": "Dansken", "email": , "subscribed": True }, { "id": 2, "first_name": "Mariejeanne", "last_name": "Edgar", "email": , "subscribed": False }, { "id": 3, "first_name": "Sheila", "last_name": "McBeith", "email": , "subscribed": False }, { "id": 4, "first_name": "Duncan", "last_name": "Kull", "email": , "subscribed": True }, { "id": 5, "first_name": "Rodger", "last_name": "Lockhart", "email": , "subscribed": False }] # Start your code below this line. 

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 Programming questions