Let us worry about your assignment instead!

We Helped With This Python Programming Assignment: Have A Similar One?

More InfoPython Project Helper

Assignment Description




Purpose. 2

Assignment Background. 2

Requirements:. 2

Code/Comment Format. 4

Sample Output. 4

What to Deliver. 5

Notes. 5

Grading. 5


















In this assignment, you will be demonstrating your understanding and use of python constructs, as covered in module 2.


This assignment is design to help you practice your skills at working with files. You will read data from a CSV file and, following input from the user, save view of the data to a CSV file.



NOTE:  You are required to use the given dataset found in the attached file named:



1.      Let’s read the data into memory.

a.       Using what you have learned in the past 2 modules, create a load_census_data function.

                                                              i.      The function must use with to open the file

                                                            ii.      Using the csv module (https://docs.python.org/3.6/library/csv.html#csv.DictReader), you must read the contents of the file

                                                          iii.      Verify

1.      that each row has 7 keys (the number of columns)

2.      that each of the column names (keys) is found in each row

3.      that all values are ints

                                                          iv.      Place each validated row (from iii) into a list.

                                                            v.      Any row that does not have valid data must be discarded (not added to the list)

                                                          vi.      The function must return a tuple by converting the list into a tuple

2.      Invoke load_census_data to get the data stored in the CSV file by passing the path to the file to the load_census_data function. It is OK to hard code the path to the CSV file.

a.       Keep a reference to the resulting tuple by creating a variable

3.      Now that we have data let’s ask the user what data they want to retrieve from the data set:

a.       Create a tuple of all the column names

b.      Enumerate (https://docs.python.org/3/library/functions.html#enumerate) all the column names and display to the user.

For example

1) Zip Code

2) Total Population

3) Median Age

4) Total Males

5) Total Females

6) Total Households

7) Average Household Size

c.       ask the user which column to filter data by.

d.      Read the input from the user (the integer).

e.       Validate user input:

                                                              i.      User input corresponds to one of the sought numbers [1, 7].

                                                            ii.      If the user’s input is invalid, ask for re-entry.

                                                          iii.      Allow the user to retry three times and then exit the program if the user keeps providing an invalid value.

4.      Let’s ask the user to provide a floor value to filter our data by.

a.       Read the input from the user.

b.      Validate the user input:

                                                              i.      User input is a positive integer.

                                                            ii.      In the same way as 2eiii, allow three retries and then exit the program.

5.      Now that we have the column name and a floor value to filter by, we need to filter the data by writing filter_data_by_column_and_floor (place the function in the same file as load_census_data and declare the new function right below it to keep your code organized).

a.       the function must take a tuple (our data), a column name, and a floor value as parameters

b.      iterate through each row of the data and build a new list of all the “rows” having the selected column’s value greater than the floor value.

c.       Return a tuple built from the list created in b.

6.      Invoke  filter_data_by_column_and_floor with the appropriate arguments:  the tuple of rows (our data), the column name selected by the user at step 3. (we want the string value  here e.g. “Zip Code”.), the floor value selected by the user at step 5.

7.      Now that we have data filtered let’s ask the user to know what column they want to sort by.

a.       Read the input from the user (the integer).

b.      Remember to validate the user input:

                                                              i.      the input corresponds to one of the sought numbers[1, 7].

                                                            ii.      Apply the same validation you did in 3.

8.      Using the sorted function (https://docs.python.org/3.6/library/functions.html#sorted), sort the filtered data by the column name selected by the user. You may need to create a function as key to sort. (use the default sorting order).

9.      Now, let’s save our data to a CSV file so the user can use it later.  We are going to place the file into a folder named exports.

a.       Create a folder named exports if it does not already exist ( https://docs.python.org/3/library/os.html#os.makedirs ). It is OK to create it wherever you want on the file system.

b.      Prompt the user for a file name (make sure that is ends with “.csv” and is not empty).

c.       Use the filename in conjunction with the “os.join” python function to create the path ( https://docs.python.org/3/library/os.path.html#os.path.join ) where the file will be saved under the folder exports

d.      Make sure that the file does not already exist (ask for a new filename if it does)

                                                              i.      Allow the user to retry three times and then exit the program if the user keeps providing an invalid filename.

e.       Write the filtered, sorted data to the file.

                                                              i.      Make sure to use with to open the file

                                                            ii.      Use the csv module to write the file (https://docs.python.org/3.6/library/csv.html#csv.DictWriter).

Code/Comment Format


Good code includes well named variables that are consistent from the beginning to the end of the program.  Naming of objects should be self-explanatory.  For instance, iterator_for_noun_list is much better than i.


Every program consists of a sequence of paragraphs, each of which has objectives, and which builds on the previous paragraphs. We are mostly interested in objectives that are valid at the end of the program so we can verify the program's design. The following is a preferred form for such paragraph headings.  The # sign is adequate when the comment is a single line.


#This is an in-line comment – used to document the code for you, or anyone else, that intends

#To extend the code


In-line comments are helpful when one has to go back to the code 6 months later to make changes. 


For doc strings, python allows the use of triple quotes.  The triple quotes can be either single or double quotes.  A doc sting is generally used as user documentation.  It does not need to include details of the implementation of the program, but instead it provides documentation as how to use the API for the program (input, output etc.)


For example:



This is an example of a doc string

It allows multiple lines within the string.




This is an example of a doc string

It allows multiple lines within the string.



This becomes significant when using functions, classes etc. as the triple quotes help to self-document the parameters and return values of the function.


What to Deliver


You are required to supply Last Name_First Name_Assignment2.py and all of the files used for the assignment with the resources folder in a zip format.  Otherwise, the program will not run for your facilitator, which will be a deduction.




·         Assignments can be submitted once.  If extenuating circumstances exist, contact your facilitator.

·         Start by identifying and ordering the objectives.

·         There are no testing requirements for this assignment.  However, it would be prudent to make sure your program does not crash and all input validation is performed correctly.

·         Note the statement in the syllabus on timeliness of submissions (the gist being that all assignments must observe the deadlines).  A ten point deduction per day late up to 20 points.  After 2 days late, a 0 will be given.  Please see the syllabus.  This is waived ONLY with the prior approval of your facilitator.




Requirement                            Points


1                                                                                            18              (i. thru vi. 3 points each)

2                                                                                            4

3                                                                                            23 (a thru d 5 points each, ei-iii 1 point each)

4                                                                                            6  ( a – 2 points, bi-ii, 2 points each)

5                                                                                            9 (a-c 3 points each)

6                                                                                            4

7                                                                                            6  ( a – 2 points, bi-ii, 2 points each)

8                                                                                            10

9                                                                                            20 – (a-d 4 points each, ei-ii 2 points each)


Frequently Asked Questions

Is it free to get my assignment evaluated?

Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.

How much does it cost?

The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):

Regular homework$20 - $150
Advanced homework$100 - $300
Group project or a report$200 - $500
Mid-term or final project$200 - $800
Live exam help$100 - $300
Full thesis$1000 - $3000

How do I pay?

Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.

Why do I need to pay in advance?

We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.

Do you do essays?

No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.

Why there are no discounts?

It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for $100, we could tell that the price is $200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.

Do you do live tutoring?

No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.

What happens if I am not satisfied with the solution?

Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On

soc fb soc insta

Paypal supported