1. Python Basic Keywords Flashcards

1
Q

What does “False” do?

A

Boolean value representing false.
(Boolean value = value that is true or false)

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

What does “None” do?

A

Represents the absence of a value.

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

What does “True” do?

A

Boolean value representing true.

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

What does “and” do?

A

The ‘and’ checks if BOTH things are True.

Logical AND operator.
# Let’s say you’re checking if you’re allowed to go to a party.
# You need to be on the guest list AND you need to bring a ticket.

on_guest_list = True # You ARE on the guest list
has_ticket = True # You DO have a ticket

if on_guest_list and has_ticket:
print(“You can enter the party!”)

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

What does “as” do?

A

Used to create an alias, especially in imports.

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

What does “assert” do?

A

Used for debugging; tests if a condition is true.

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

What does “async” do?

A

Declares an asynchronous function.

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

What does “await” do?

A

Waits for completion of an async function.

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

What does “break” do?

A

Exits the nearest enclosing loop.

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

What does “class” do?

A

Used to define a class.

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

What does “continue” do?

A

Skips the rest of the loop and starts next iteration.

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

What does “def” do?

A

Used to define a function.

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

What does “del” do?

A

Deletes a reference to an object.

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

What does “elif” do?

A

Else if condition in an if statement.

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

What does “else” do?

A

Default block when if/elif conditions are false.

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

What does “except” do?

A

Handles exceptions in try-except blocks.

17
Q

What does “finally” do?

A

Block that always executes after try-except.

18
Q

What does “for” do?

A

Starts a for loop.

19
Q

What does “from” do?

A

Used with import to specify the module.

20
Q

What does “global” do?

A

Declares a global variable.

21
Q

What does “if” do?

A

Starts a conditional block.

22
Q

What does “import” do?

A

Imports a module.

23
Q

What does “in” do?

A

Checks membership or used in for loops.

24
Q

What does “is” do?

A

Tests object identity.

25
What does "lambda" do?
Creates an anonymous function.
26
What does "nonlocal" do?
Declares a non-local variable.
27
What does "not" do?
Logical NOT operator.
28
What does "or" do?
Logical OR operator.
29
What does "pass" do?
Does nothing; placeholder.
30
What does "raise" do?
Raises an exception.
31
What does "return" do?
Exits a function and optionally returns a value.
32
What does "try" do?
Starts a try-except block.
33
What does "while" do?
Starts a while loop.
34
What does "with" do?
Simplifies exception handling in context managers.
35
What does "yield" do?
Pauses function and yields a value (used in generators).