So I finished day one and had a few questions about general good coding principles
1. She brought up the idea of nesting code, is this a good principle to adopt professionally?
For example:
Taking a non-nested program like this one, which tells you the number of characters in your name.
Ex: Bill = 4
-name = input (“What is your name?”)
-print(len(name))
VERSUS NESTING IT LIKE THIS (which she provides as an example)
print(len((input(“What is your name?))))
In terms of practicality and functionality, especially for future projects which is the better practice moving forward? Keeping the code elementary or trying to nest it?
2. This is a follow up that ties into the nesting question, but I am asking this to clear up some confusion.
So the function of this line of code is to create a new line for the input. Meaning that when the user has the option to input, it is on a new line, not the same one as the instructions.
Which is the better line of code (professionally)?
A:
- input(“What is your name? \n”)
OR
B:
- Print (“What is your name?”)
- input()