2. Python Core Terms Flashcards

1
Q

What is an “int”?

A

A data type representing whole numbers.

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

What is a “float”?

A

A data type representing decimal numbers.

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

What is a “str”?

A

A data type for sequences of characters (text).

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

What is a “bool”?

A

A data type with two values: True or False.

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

What is a “list”?

A

An ordered, mutable collection of items.

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

What is a “tuple”?

A

An ordered, immutable collection of items.

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

What is a “dict”?

A

A collection of key-value pairs.

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

What is a “set”?

A

An unordered collection of unique items.

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

What does “if” do?

A

Executes code only if a condition is true.

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

What does “for” do?

A

Loops over items in a sequence.

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

What does “while” do?

A

Repeats a block while a condition is true.

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

What does “break” do?

A

Exits the nearest loop.

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

What does “continue” do?

A

Skips to the next loop iteration.

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

What does “def” do?

A

Defines a function.

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

What is a parameter?

A

A variable in a function definition.

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

What is an argument?

A

A value passed to a function.

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

What is a lambda function?

A

An anonymous, single-expression function.

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

What does “*args” do?

A

Collects extra positional arguments.

19
Q

What does “**kwargs” do?

A

Collects extra keyword arguments.

20
Q

What is the difference between local and global variables?

A

Local variables exist within functions; global variables exist throughout the program.

21
Q

What is “try” used for?

A

To attempt code that might raise an error.

22
Q

What does “except” do?

A

Catches and handles errors.

23
Q

What does “finally” do?

A

Always runs, even if there’s an error.

24
Q

What does “raise” do?

A

Manually triggers an error.

25
What is a TypeError?
Occurs when an operation is applied to the wrong type.
26
What is a ValueError?
Occurs when a function gets an argument of right type but wrong value.
27
What is a KeyError?
Occurs when a dictionary key isn't found.
28
What is a class?
A blueprint for creating objects.
29
What is an object?
An instance of a class.
30
What is "__init__"?
Constructor method in a class.
31
What is "self"?
Refers to the current object instance.
32
What is inheritance?
A way for a class to inherit methods and properties from another.
33
What is encapsulation?
Restricting access to parts of an object.
34
What is the difference between a method and a function?
A method is a function inside a class.
35
What does "import" do?
Loads a module or library.
36
What does "from ... import ..." do?
Imports specific parts of a module.
37
What is the difference between standard and third-party libraries?
Standard comes with Python; third-party must be installed (e.g., pandas).
38
What is "None" in Python?
Represents the absence of a value.
39
What is the difference between "is" and "=="?
is' checks identity; '==' checks equality.
40
What does "mutable" mean?
Can be changed after creation (e.g., lists).
41
What does "immutable" mean?
Cannot be changed after creation (e.g., strings).
42
What is indentation?
Whitespace that defines code blocks.
43
How do you write a comment in Python?
Use '#' for single-line or triple quotes for multi-line comments.