naming conventions Flashcards

1
Q

Name Constants

A

Use all uppercase, can also use with snake case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name Classes

A

CapitalizedWords - camel case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is ugly

A

Capitalized words with underscores

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Match each definition to its corresponding naming style:

(1) Words are separated with a single capitalized letter and the first word starts with a lowercase letter.
(2) Words are separated with an underscore and all words start with a lowercase letter.
(3) Words are separated with a single capitalized letter and the first word starts with an uppercase letter.

A

1) Lower camel case
2) snake Case
3) Upper camel case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Upper Camel Case is also known as…

A

Pascal Case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Variable names must start with?

A

A letter or underscore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What can a variable name not start with

A

Number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can a variable name contain special symbols

A

No, Only alphanumeric characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

style/PEP8 variable names

A

snake case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

style/PEP8 functions names

A

snake case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Should variable names be pronounceable?

A

Yes, try not to abbreviate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Should variable names be easy to do search on?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What letters should you never use as single character variable names.

A

Never use the characters ‘l’ (lowercase letter el), ‘O’ (uppercase letter oh), or ‘I’ (uppercase letter eye) as single character variable names.

In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use ‘l’, use ‘L’ instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

style/PEP8 if you have to use a python keyword as a variable/function name add ? at the end of the name

A

underscore

class_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Boolean Variables:

Usually, the names of variables that only take boolean values (True and False) should start with the following prefixes:

A

is
has

Examples:

is_valid
is_logged_in
is_open
is_finished
has_pets
has_next
has_children
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How many spaces to indent

A

4 spaces

17
Q

spaces (4) or Tables which does python prefer

A

spaces (4)

18
Q

What do you need for a multi line conditional

A

( ) parentheses [you can also add extra indentation to the conditional]