ALL RIGHTS RESERVED.
Python Syntax Exam Study Guide.
Indentation - Answers✔block (grouping statements, especially when statements are not expressions)
\ - Answers✔breaking lines (useful when end-of-line and/or indentation has a special meaning)
# - Answers✔commenting (until end of line)
< > <= >= - Answers✔comparison
min / max - Answers✔comparison (min / max (binary or more))
smallest / biggest element
cmp - Answers✔comparison (returns 3 values (i.e. inferior, equal or superior))
class X:
"""...
"""
def x():
"""...
""" - Answers✔documentation comment
Err:510 - Answers✔equality / inequality (deep)
string equality & inequality
is / is not - Answers✔equality / inequality (shallow)
gc.collect() - Answers✔force garbage collection
( ... ) - Answers✔grouping expressions
__file__ - Answers✔information about the current line and file
eval - Answers✔runtime evaluation
, ©SIRJOEL EXAM SOLUTIONS 2024/2025
ALL RIGHTS RESERVED.
exec - Answers✔runtime evaluation
case-sensitive - Answers✔tokens (case-sensitivity (keywords, variable identifiers...))
[_a-zA-Z][_a-zA-Z0-9]* - Answers✔tokens (variable identifier regexp)
CamelCase for classes, underscores for methods - Answers✔tokens (what is the standard way for
scrunching together multiple words)
= - Answers✔variable assignment or declaration (both)
global v1, v2 - Answers✔variable assignment or declaration (declaration)
functools.partial(f, a) - Answers✔partial application (in the examples below, a normal call is "f(a,b)")
(give the first argument)
lambda a, b: ... - Answers✔anonymous function
f(a,b,...) - Answers✔function call
f() - Answers✔function call (with no parameter)
__getattr__ - Answers✔function called when a function is not defined (in dynamic languages)
def f(para1, para2, ...): ... - Answers✔function definition
return - Answers✔function return value (breaks the control flow)
breaking control flow (returning a value)
inspect.stack()[1] - Answers✔runtime inspecting the caller information
continue / break - Answers✔breaking control flow (continue / break)
try: a except exn: ... - Answers✔exception (catching)
finally - Answers✔exception (cleanup: code executed before leaving)
raise - Answers✔exception (throwing)
if c: ... - Answers✔if_then
b1 if c else b2 - Answers✔if_then_else
if c:
b1
elif c2: