I need help with a class assignment!

I’m brand new to coding and have an assignment in class to review and contrast the design of each of the parts of the below code. Can anyone help with the categories I should use to compare and contrast each part? Not asking to do the assignment for me, just help get me started and pointed in the right direction. Thanks!

numbers = [[4, 3], [1,2], [154,233], [555,-444]]

def show_add_pair(pair):
    print(str(pair[0]) + '+' + str(pair[1]) + '= ' + str(pair[0] + pair[1]))

print('\nPart 1')

print('\nPart 2')

print('\nPart 3')
for n in numbers:

print('\nPart 4')
[show_add_pair(x) for x in numbers]

Hi there @MarkStanczyk. First of all, well done for pointing out to us that this is a class assignment, seems like you have read the forum guidelines well!

Not quite sure if this is what you are looking for, but maybe these points will help you get started.

1. Function Definitions:

  • Identify and describe the purpose of each function in the code.
  • Compare the function names, arguments, and implementations.
  • Note if there are any differences in the function designs, such as input parameters or return values.

2. Function Calls:

  • Analyze how each function is called in different parts of the code.
  • Compare the arguments passed to each function call.
  • Note if there are any differences in the way functions are invoked.

3. Output Generation:

  • Examine how output is generated in different parts of the code.
  • Compare the format and content of the output.
  • Identify if there are any variations in the output generated by different parts of the code.

4. Data Structures:

  • Describe the data structure used in the ‘numbers’ variable.
  • Compare how elements of the ‘numbers’ list are accessed and used in different parts of the code.

5. Efficiency:

  • Consider the efficiency of the code and/or how fast it is and how many lines of code are needed to achieve the task.

Could you also edit your post to add code formatting to the code you’ve provided, to keep it nice and neat?


Thank you for your quick response! This definitely helps to orient my thinking.
How do I edit my post to add code formatting? Not sure where to find the “edit post” icon.

1 Like

I already edited your post to include code formatting. However, you can edit your post by clicking on the pencil icon.
Code formatting works like this:

print("Hello world!")

So, three backticks + the language name, then the code, then three backticks (and how I got the backticks to show is by using 4 backticks above the 3; don’t normally do that).

print("Hello world!")

Great you found it useful. If my post solved your problem, please mark it as a solution, thanks :smile: