My fourth Python project

Hello guys ! How are you ?

I present my fourth project in Python, which deals with lists.

It is part of the data science career path.

As always, I kindly ask you to take a look and give me suggestions.

Thank you !

Follow the link:

The project is well done! I just have two points I want to mention.

  1. Step 6 asks you to use the .append() method to add ("visual arts", 93) to gradebook. You’ve used concatenation here.
  2. There are a lot of blank lines in your code, much of which is unnecessary. You can find the Python style guide here.

Thank you ! In fact, I was unsure in step 6. I tried using .append () but it didn’t work, so I concatenated it. I will go back to the project and try again. Thank you very much for the style guide!

1 Like

Hello, Dr !

I corrected the project.


Nice to see that you’ve used .append()! Again, I’ll mention that there are still many blank lines. When your code gets longer and more complex, too many blank lines will drastically increase the line count and potentially make your code harder to read.

I left a line of space between comments and code … is it still too much?

Right now, it doesn’t affect legibility that much, but it will as your programs get longer. There isn’t a set right or wrong answer, but blank lines (where specific uses of them aren’t mentioned in the PEP 8 style guide above) are typically used to separate blocks of related code and logic.

Personally, I would do something like this.
# STEP 1: Create a list called subjects and fill it with the classes you are taking:
subjects = ["physics", "calculus", "poetry", "history"]

# STEP 2: Create a list called grades and fill it with your scores:
grades = [98, 97, 85, 88]

In my example above, it would also make it a bit more clear that #STEP 1 is referring to the line of code directly below it.

Here’s a sample program that uses whitespace effectively.

hmmmmm … I understand better now … thanks for the example. I will modify the project and soon show you again.

Hello ! “Fixed” the gaps between comments. I followed the model you showed me.
Please see the link:

Thank you again !

1 Like

Looks great! Happy coding!