• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 9 pages
Exam (elaborations)

Python Syntax Exam Study Guide.

Document preview thumbnail
Preview 2 out of 9 pages

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

Content preview

©SIRJOEL EXAM SOLUTIONS 2024/2025

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:

Document information

Uploaded on
December 10, 2024
Number of pages
9
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
sirjoel
3.6
(20)
Sold
136
Followers
13
Items
12750
Last sold
4 weeks ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions