CS2204 Homework: Group Assignments (Solution)

$ 20.99
Category:

Description

Objectives
Learn to read existing Python code
Find and correct syntax errors in code
Find and correct logical errors in code Understand PEP 8 style requirements
Background
Also, the results of the program is supposed to look like this
Student One
Student Two …

Student Three
Student Four …

Student Five
Student Six …
Tasks
1. There are a few syntax errors in the provided script ( group_assignment.py ). You have to x this rst (30 pts)
2. There is a logical error in the program. It does not implement the assignment properly (see the requirements, above). Understand and x this problem by modifying the existing code, or – if it feels easier – by completely rewriting the algorithm (50 pts)
3. Make sure, you maintain the proper output format. The current script might do this right, just make sure you do not ruin it. (20 pts)
4. There are several PEP 8 style errors in the code. Fix these, otherwise you will be penalized.
Hints
There are a few constructs in the code, which might be new to you. While most of these are not critical to understand to x the program, here are some brief explanations (we learn about these more, later).
random.sample(population, k) : it picks k number of samples (without replacement) from population . Both population and the returned samples are Python lists. If k equals to the
length of the population list, the result is effectively a randomly shu ed version of that list.
Example:
1from random import sample
2
3vals = [1, 2, 3, 4, 5, 6, 7]
4shuffled = sample(vals, len(vals)) 5print(shuffled)

zip(list_a, list_b, …) : returns a new list (more properly, an iterator object), containing
tuples by merging the original lists elementwise. The most typical use-case is with for loops, so we can iterate over the elements of multiple lists in parallel.
Examples:
1list_a = “one”, “two”, “three”
2list_b = “uno”, “dos”, “tres”
3print(list(zip(list_a, list_b)))

1for a, b in zip(list_a, list_b): 2 print(a, “–“, b)

Grading
Penalties
Points will be deducted if you fail to set __author__ variable (-10 pts) and for each PEP 8 style errors (-1 pt for each) in your program.
Submission
Please, upload the nal version of the following le(s) (and only those le(s)) to Brightspace:
group_assignment.py

Reviews

There are no reviews yet.

Be the first to review “CS2204 Homework: Group Assignments (Solution)”

Your email address will not be published. Required fields are marked *