Coding Basics Flashcards

1
Q

What type of code should be in a method or function

A

Code that performs a discrete task and task code that is used more than once

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

What are arguments?

A

Variables you pass into functions/methods

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

What happens when a return statement is executed

A

A variable is returned

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

What is the difference between methods and functions?

A

Functions are standalone code blocks while methods are code blocks associated with an object

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

What is a module

A

a set of functions and contains an interface for other modules to integrate with

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

In a venv if you install a library what directory is it stored in

A

The /lib directory

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

Where directory is an executable script stored at in a venv if you install it?

A

in the /bin directory

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

What command activates the python interactive shell?

A

python -i

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

what are the three naming conventions for variables in python

A

Cannot start with a number [0-9]
Cannot conflict with a language keyword
Can contain: [A-Z a-z 0-9 _ -]

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

When should code be encapsulated into a method or a function

A

Code that performs a discrete task

Task code that is used more than once

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

What is Object-oriented programming (OOP) based off of

A

Encapsulation
Data abstraction
Polymorphism
inheritance

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

What are functions defined within a class known as

A

class methods

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

How do you create a private variable in Python

A

by putting a leading _ in front of a variable name

EX. _MyVariable

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

What do you call a python file that is intended to be executed

A

A script

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

What does the if__name__ == __main__ block do

A

executes the script, initialize any global variables, and so on and then call the scripts main function

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

What is a stack trace

A

shows the calling stack of statements all the way from the top level script that is being executed down to the statement that has produced the error

17
Q

How do you read a stack trace

A

Read the last line first

Review the the call stack from Top to Bottom

18
Q

What command allows you to interact with your code in the intereactive shell

A

python -i

19
Q

What is a code review

A

when developers look over the codebase, a subset of code, or specific code changes and provide feedback.

20
Q

What are the four most common types of code reviews

A

Formal Code review
Change-based code review
Over-the-shoulder code review
Email pass-around

21
Q

Describe Formal code review

A

is where developers have a series of meetings to review the whole codebase

22
Q

Describe Change-based code review

A

also known as a tool-assisted code review, reviews code that was changed as a result of a bug, user story, feature, commit, etc.

23
Q

Describe an Emil pass-around review

A

piggybacks on the automatic emails sent by source code management systems when a checkin is made. When the emails are sent, it is up to the other developers to review the code changes that were made in that checkin.