I need to learn python Flashcards

(27 cards)

1
Q

Define Python.

A

A high-level, interpreted programming language known for its readability and versatility.

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

What does PEP stand for in Python?

A

Python Enhancement Proposal, a design document providing information to the Python community.

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

True or false: Python is a compiled language.

A

FALSE

Python is an interpreted language, meaning code is executed line by line.

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

Fill in the blank: Python uses ______ to define code blocks.

A

Indentation

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

What is a list in Python?

A

A mutable, ordered collection of items, defined by square brackets.

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

Define tuple.

A

An immutable, ordered collection of items, defined by parentheses.

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

What is the purpose of the print() function?

A

To output data to the console.

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

True or false: Python supports multiple inheritance.

A

TRUE

A class can inherit from multiple parent classes in Python.

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

What does the len() function do?

A

Returns the number of items in an object.

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

Fill in the blank: A dictionary in Python is defined using ______.

A

Curly braces

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

What is the purpose of if statements?

A

To execute a block of code conditionally based on a boolean expression.

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

Define list comprehension.

A

A concise way to create lists using a single line of code.

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

What is a function in Python?

A

A block of reusable code that performs a specific task.

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

True or false: Python uses static typing.

A

FALSE

Python uses dynamic typing, allowing variable types to change at runtime.

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

What is the purpose of the import statement?

A

To include external modules or libraries in your code.

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

Fill in the blank: The __init__() method is the ______ method in a class.

17
Q

What is an exception in Python?

A

An error that occurs during program execution, disrupting normal flow.

18
Q

Define lambda function.

A

A small anonymous function defined with the keyword ‘lambda’.

19
Q

What is the purpose of the with statement?

A

To simplify exception handling by encapsulating common preparation and cleanup tasks.

20
Q

True or false: Python supports regular expressions.

A

TRUE

The ‘re’ module provides support for regular expressions in Python.

21
Q

What is the main() function?

A

The entry point of a Python program, executed when the script runs.

22
Q

Fill in the blank: The for loop iterates over ______.

23
Q

What is a module in Python?

A

A file containing Python code that can define functions, classes, and variables.

24
Q

Define decorator.

A

A function that modifies the behavior of another function.

25
What does the **break** statement do?
Exits the nearest enclosing loop prematurely.
26
True or false: Python can be used for **web development**.
TRUE ## Footnote Frameworks like Django and Flask enable web development in Python.
27
What is the purpose of **self** in class methods?
To refer to the instance of the class within its methods.