Feedback about my project

Here’s my Time Calculator- Scientific Computing with Python Projects.
I will be very grateful if someone takes the time to look at it and makes me any comment.

It’s my first Python project and I would like to improve my coding skills. I’ve tried to make the code as clean as possible, if you think I didn’t achieve it, tell me!

Also I had some trouble working with repl.it. How I have to upload my code? I’ve done properly?

PD : Sorry for the spanish comments, I’ve used them to organize my self!

Here’s my code

@adria.lloreda Bienvenido al forum. I suggest you check that your code conforms to the PEP8 standard. There is an online tool here http://pep8online.com

What would be better is to integrate into your text editor a way to check your code as you are typing it. It will help your code look cleaner and warn you of errors. I use Vim to edit text so I have installed programs such as
curl exuberant-ctags ack-grep pep8 flake8 pyflakes isort yapf
to help me code better. Now my code is cleaner and I get warned of errors such as unused imports.

The Spanish comments are great. I can understand them.

Gracias Brandon. Thanks for your suggestion, it’s a nice tool. I will search some extensions for vsc.
Thanks for your time. Keep learning

Generally everything is looking rather simple and not complicated. That’s good. Below are some things I’ve noticed. Keep in mind those are just tips, pointers and other suggestions what can be looked at. Some of these can be applied also to other places in code.

  • Regarding lines
    startHour = startTime.split(" ")
    hr_minu = startHour[0].split(":")
    hr = int(hr_minu[0])
    minu = int(hr_minu[1])
    am_pm = startHour[1]

python has very handy syntax allowing simplifying such assignments and don’t deal with the indexes, for example having list with two elements and two variables to assign to elements from that list:

words = ['Word 1', 'Word 2']
first, second = words

Would assign 'Word 1' to first and 'Word 2' to second.

  • Regarding line
if new_hr > 12 and new_hr < 24:

One more handy python syntax allows chaining two separate conditions using comparison operators and comparing the same variable. For example a > 1 and a < 5 can be written as:

1 < a < 5
  • Regarding line
    else: 
        pass

else and pass is obsolete here

  • Regarding lines
        while day_index >= 7:
          day_index = day_index % 7

This while loop will never be executed more than once, as % 7 always should bring the number down under the 7.

  • Regarding lines
   if (startingDay):
        startingDay = str(startingDay)
        startingDay = startingDay.lower()
        initialDay = daysWeek.index(startingDay)

Parenthesis in if (startingDay): is not needed. Also for the following lines, assuming
that function is called correctly and startingDay has some non falsy value, this makes str type change to str. After getting rid of that and moving lower() method call three lines can be replaced by single line.

  • Regarding line
final_hr = str(new_hr) + ":" + str(new_minu) + " " + str(am_pm)

You can take a look at the so-called f-strings or format method of the str type. These can help a bit with making lines like this slightly more readable.

  • Regarding line
new_time = final_hr

I suppose comment before this line might be explaining why this assignment is done, but I’m unable to read that. :slight_smile: Why not call it new_time from the start, instead of final_hr?

  • Style guide

Definitely take a look at the mentioned PEP8 style guide for python, it contains some general guidelines how code written in python is usually formatted. Especially notice how it’s recommended to name variables, as that’s a bit inconsistent in this function.

Thank you for your valuable comments. Definitely, I will apply all your comments on this project and also, I will try to incorporate it into my new projects. I’m new in coding and I will like to improve my skills from a holistic view. Writing code that works is important, but also fundamental is how you wrote it and if you are capable of communicating with mates through it.