Module 3 Flashcards

1
Q

an instruction that a Python interpreter can execute

A

Statement

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

Python statement ends with the token NEWLINE character. But we can extend the statement over multiple
lines using line continuation character (). This is known as an explicit continuation.

A

Multi-Line Statements

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

We can use parentheses () to write a multi-line statement. We can add a line continuation statement inside
it. Whatever we add inside a parentheses () will treat as a single statement even it is placed on multiple lines

A

Implicit continuation

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

contain (groups of) other statements; they affect or control the execution of those
other statements in some way.

A

Compound Statements

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

What are the Five compound statements?

A

if, while, for, try and with

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

It is a control flow statement that will execute statements under it if the condition is
true. Also known as a conditional statement.

A

if statement

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

repeatedly executes a code block while a particular
condition is true. Also known as a looping statement.

A

while statements

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

we can iterate any sequence or iterable variable. The
sequence can be string, list, dictionary, set, or tuple. Also known as a looping statement.

A

for statement

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

specifies exception handlers

A

try statements

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

Used to cleanup code for a group of statements, while the with statement allows
the execution of initialization and finalization code around a block of code.

A

with statements

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

Apart from the declaration and calculation statements, Python has various simple statements for a specific
purpose.

A

Simple Statements

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

is a null operation. Nothing happens when it executes. It is useful as a placeholder when a statement
is required syntactically, but no code needs to be executed.

A

The pass statement

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

are used to compute and write a value. An expression statement
evaluates the expression list and calculates the value.

A

Expression statements

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

used to delete objects/variables.

A

The del statement

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

we can return a value from a function when
called.

A

The return statement

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

contains the variable to delete separated by a comma.

A

target_list

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

used to import modules. We can also import individual classes from a module.
Python has a huge list of built-in modules which we can use in our code.

A

The import statement

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

used inside the loop to exit out of the loop

A

break Statement

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

skip the current iteration and move to the next iteration.

A

continue Statement

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

Terminate the current loop. Use the break statement to
come out of the loop instantly.

A

break

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

Skip the current iteration of a loop and move to the next
iteration

22
Q

Do nothing. Ignore the condition in which it occurred and
proceed to run the program as usual

23
Q

The comments are descriptions that help programmers to understand the functionality of the program. Thus,
comments are necessary while writing code in Python.

A

Python Comments

24
Q

There is no separate way to write a ____________. Instead, we need to use a hash sign at the beginning
of each comment line to make it a ___________

A

Multi-Line Comments

25
are indicated by a hash sign(#)
Single-line Comment
26
a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement. They should start with a # and a single space.
Inline Comments
27
used to provide descriptions of files, classes, and functions
Block comments
28
We can use multi-line strings (triple quotes) to write multi-line comments. The quotation character can either be ‘ or “. Python interpreter ignores the string literals that are not assigned to a variable.
Using String Literals for Multi-line Comments
29
describe Python classes, functions, constructors, methods. The docstring comment should appear just after the declaration.
Docstring Comments
30
built-in module to get the list of keywords. Also, this module allows a Python program to determine if a string is a keyword.
keyword module
31
reserved words that have a special meaning
Python keywords
32
Apart from a keyword module, we can use the _________ to get the list of keywords
help() function
33
It return a sequence containing all the keywords defined for the interpreter.
keyword.kwlist
34
Return True if s is a Python soft keyword.
keyword.issoftkeyword(s)
35
Sequence containing all the soft keywords defined for the interpreter.
keyword.softkwlist
36
used to represent truth values, known as boolean values
True and False
37
returns True if both expressions are True. Otherwise, it will return. False.
and keyword
38
returns a boolean True if one expression is true, and it returns False if both values are false
or keyword
39
returns boolean True if the expression is false.
not keyword
40
returns return True if the memory address first value is equal to the second value.
is keyword
41
returns True if it finds a given object in the sequence (such as list, string).
in keyword
42
43
44
45
46
47
48
49
50