Learn Python in 100 days thread

xiceman191

Superstar
Joined
Jan 23, 2015
Messages
6,260
Reputation
2,328
Daps
29,826
Just bought this and I'm gonna start going through this course. I need to really focus on leveling up and gaining more skills.
 

King

The black man is always targeted.
Joined
Apr 8, 2017
Messages
18,670
Reputation
4,029
Daps
79,620
Copped this hoe, finna take this big bytch down like Lizzo :win:
 

King

The black man is always targeted.
Joined
Apr 8, 2017
Messages
18,670
Reputation
4,029
Daps
79,620
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()
 
Top