Revature Python Flashcards

1
Q

What is the difference between a interpreter and a compiler?

A

Compilers execute the whole source code into machine readable code. A interpretor executes code line by line. Interpretors are generally slower due to having to process the code while executing.

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

What is Repl

A

It stands for read eval print loop. It is a interactive pyhton coding environment that allows one to execute code immediately Some good use cases of this would be for functional coding.

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

What is a compound statement?

A

A compound statement are groups of statements together. An example would be a if forloop block.

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

What is a namespace?

A

A namespace is a container that holds the name of (variables, functions, objects) and holds their values to avoid conflicting name titles.

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

What is a scope of a variable

A

The scope determines where the variable can be accessed. For example we cant access a variable that hasnt been instantiated yet.

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

What are some different operators in python?

A

There are arithmetic comparison logical assignment, membership and identity

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

What are functions?

A

They’re blocks of reusable code to perform task

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

What is a lambda function and how do you create one?

A

Lambda functions are one line function

syntax: lambda arguements: expression
example: square = lambda x: x**2

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

What is a tuple

A

A tuple is an immutable collection of elements

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

What is a module? How do we import it?

A

A module is a file containing python code. You can import it by using the import module_name. For best practices you don’t want to import the the entire module, but just what you need. For example from module _name import function_name

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

What is a datetime object?

A

a datetime object is a object used to collect or calculate the current date and time of the machine.

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

What is regular expression?

A

Regular expression (Regex) is a sequence of characters used for string matching and manipulations. It is especially useful for login credentials to ensure user input falls in line with the guidelines.

import re
result = re.match(r”\d+”, “123abc”)

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

Name some Collection Modules for data collection?

A

Counter: Counts occurrences of elements.

deque: Double-ended queue.

defaultdict: Dictionary with a default value.

namedtuple: Tuple with named fields.

OrderedDict: Maintains insertion order.

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

What is a class, whats is an object?

A

Classes are blue prints for objects. Objects are instances of a class.

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

What are exceptions?

A

Exceptions: A problem that occur during program execution disrupting the flow of the program. They are used to handle runtime errors

Handling: Use try, except, else, and finally.

Example:
python
Copy code
try:
result = 10 / 0
except ZeroDivisionError:
print(“Cannot divide by zero!”)

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

What is a list

A

A list is a ordered collection of items characterized by indexes.

17
Q

How to open files?

A

You open files with the open(filename,mode) function

Modes:
read
write
append
binary

18
Q

What is Pandas used for

A

Pandas is a python library used for data manipulation and analysis

19
Q

What is flow control?

A

Flow control determines the execution order of code