Advanced Python Flashcards

1
Q

What do generators do?

A

They yield information back.

Since they do not return, they’re able to keep track of current variables.

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

The __init__ function is called automatically when a new class is instantiated.

A

True

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

What is Python?

A

Python is a high-level, interpreted, general-purpose programming language. it can be used to build almost any type of application with the right tools/libraries.

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

What is PEP 8 and why is it important?

A

PEP stands for Python Enhancement Proposal. is an official design document providing information describing a new feature for Python.

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

What is a dynamically typed language?

A

Type-checking can be done at two stages -

Static - Data Types are checked before execution.
Dynamic - Data Types are checked during execution.

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

What are the benefits of using Python?

A

Python is a general-purpose programming language that has a simple, easy-to-learn syntax that emphasizes readability and therefore reduces the cost of program maintenance.

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

What is lambda in Python? Why is it used?

A

Lambda is an anonymous function in Python, that can accept any number of arguments, but can only have a single expression.
It is used in situations requiring an anonymous function for a short time period.

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

What is the difference between Python Arrays and lists?

A

Arrays in python can only contain elements of same data types and consumes far less memory than lists.

Lists in python can contain elements of different data types consuming large memory.

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

What is slicing in Python?

A

Syntax for slicing is [start : stop : step]
start is the starting index from where to slice a list or tuple
stop is the ending index or where to sop.
step is the number of steps to jump.
Default value for start is 0, stop is number of items, step is 1.
Slicing can be done on strings, arrays, lists, and tuples.

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

What is an Interpreted language?

A

An Interpreted language executes its statements line by line.

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