Coding Basics Flashcards
What type of code should be in a method or function
Code that performs a discrete task and task code that is used more than once
What are arguments?
Variables you pass into functions/methods
What happens when a return statement is executed
A variable is returned
What is the difference between methods and functions?
Functions are standalone code blocks while methods are code blocks associated with an object
What is a module
a set of functions and contains an interface for other modules to integrate with
In a venv if you install a library what directory is it stored in
The /lib directory
Where directory is an executable script stored at in a venv if you install it?
in the /bin directory
What command activates the python interactive shell?
python -i
what are the three naming conventions for variables in python
Cannot start with a number [0-9]
Cannot conflict with a language keyword
Can contain: [A-Z a-z 0-9 _ -]
When should code be encapsulated into a method or a function
Code that performs a discrete task
Task code that is used more than once
What is Object-oriented programming (OOP) based off of
Encapsulation
Data abstraction
Polymorphism
inheritance
What are functions defined within a class known as
class methods
How do you create a private variable in Python
by putting a leading _ in front of a variable name
EX. _MyVariable
What do you call a python file that is intended to be executed
A script
What does the if__name__ == __main__ block do
executes the script, initialize any global variables, and so on and then call the scripts main function
What is a stack trace
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
How do you read a stack trace
Read the last line first
Review the the call stack from Top to Bottom
What command allows you to interact with your code in the intereactive shell
python -i
What is a code review
when developers look over the codebase, a subset of code, or specific code changes and provide feedback.
What are the four most common types of code reviews
Formal Code review
Change-based code review
Over-the-shoulder code review
Email pass-around
Describe Formal code review
is where developers have a series of meetings to review the whole codebase
Describe Change-based code review
also known as a tool-assisted code review, reviews code that was changed as a result of a bug, user story, feature, commit, etc.
Describe an Emil pass-around review
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.