Free Online Flashcard Deck

1 Python Syntax and Program Structure Free Online FlashCards

Study 1 Python Syntax and Program Structure with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What distinguishes an expression from a statement?

Back

Expressions produce values, while statements perform actions such as assignment, importing, defining functions, or controlling execution.

02
Front

What is a common order for a Python source file?

Back

A module docstring may come first, followed by imports, constants and configuration, function and class definitions, and program-starting code.

03
Front

Why use if __name__ == "__main__":?

Back

When a file runs directly, __name__ equals "__main__"; when imported, it does not, so the guarded main() call runs only for direct execution.

04
Front

How can one Python statement span multiple lines?

Back

A statement may continue across physical lines inside parentheses, brackets, or braces. This is usually clearer and safer than using a backslash.

05
Front

How do comments differ from docstrings?

Back

A comment starts with # outside a string and is ignored during parsing. A first string literal in a module, function, or class is a docstring.

06
Front

How does Python delimit code blocks?

Back

Indentation defines Python code blocks. A compound-statement header ends with a colon, and its controlled suite is indented beneath it; four spaces per level is conventional.

07
Front

What naming rules distinguish count from Count?

Back

Python is case-sensitive, so count and Count are different names. Names may contain letters, digits, and underscores but cannot begin with a digit.

08
Front

What does Python assignment bind?

Back

Assignment binds a name to an object; it does not necessarily copy the object. Multiple assignment can bind several names or swap references.

09
Front

What is a literal in Python?

Back

A literal is source-code notation for a value, such as 42, "hello", True, None, [1, 2, 3], or {"language": "Python"}.

10
Front

How do / and // differ?

Back

The operator // performs floor division: 7 // 2 evaluates to 3. The operator / performs true division, so 7 / 2 evaluates to 3.5.

11
Front

What is short-circuit evaluation?

Back

and and or use short-circuit evaluation, stopping when the result is determined. They return one of their operands, not necessarily True or False.

12
Front

What do print()'s sep and end control?

Back

print() writes objects as text. Its sep argument separates multiple objects, while end replaces the default trailing newline.