• Mauvais document ? Échangez-le gratuitement
  • Rédigé par des étudiants ayant réussi
  • Disponible immédiatement après paiement
  • Lire en ligne ou en PDF
Vendre
Où étudie-tu ?
La langue
Document preview thumbnail
Aperçu 2 sur 9 pages
Examen

Python Syntax Exam Questions and Correct Solutions Graded A+ (Latest Update )

Document preview thumbnail
Aperçu 2 sur 9 pages

Python Syntax Exam Questions and Correct Solutions Graded A+ (Latest Update ) 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) ct() - Answers force garbage collection ( ... ) - Answers grouping expressions __file__ - Answers information about the current line and file eval - Answers runtime evaluation 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) al(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) ()[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: b2 else: b3 - Answers if_then_else for i in xrange(10, 0, -1) - Answers loop (for each value in a numeric range, 1 decrement) for i in xrange(1, 11) - Answers loop (for each value in a numeric range, 1 increment (see also the entries about ranges)) for i in xrange(1, 11, 2) - Answers loop (for each value in a numeric range, free increment) while c: ... - Answers loop (while condition do something) ; - Answers sequence end-of-line - Answers sequence t(e) - Answers cast (computed conversion (calls an internal or a user-defined function)) n = t - Answers declaration super(Class, self).meth(args) - Answers accessing parent method class - Answers class declaration first parameter - Answers current instance __class__ - Answers get the type/class corresponding to an object/instance/value hasattr(obj, "meth") - Answers has the method class child(parent): - Answers inheritance del, __del__ - Answers manually call an object's destructor d(para) - Answers method invocation d() - Answers method invocation (with no parameter) dir - Answers methods available (o) - Answers object cloning class_name(...) - Answers object creation isinstance - Answers testing class membership automatically done based on the file name - Answers declare __all__ = [ ... ] - Answers declare (selective export) from p import * - Answers import (everything into current namespace) import p - Answers import (package (ie. load the package)) from p import name1, name2, ... - Answers import (selectively) 0 - Answers package scope string concatenation false value

Aperçu du contenu

Python Syntax Exam Questions and Correct Solutions Graded A+ (Latest Update 2024-2025)



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

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:

Infos sur le Document

Publié le
7 décembre 2024
Nombre de pages
9
Écrit en
2024/2025
Type
Examen
Contenu
Questions et réponses
$8.49

Mauvais document ? Échangez-le gratuitement Dans les 14 jours suivant votre achat et avant le téléchargement, vous pouvez choisir un autre document. Vous pouvez simplement dépenser le montant à nouveau.
Rédigé par des étudiants ayant réussi
Disponible immédiatement après paiement
Lire en ligne ou en PDF

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
TutorJosh
3.5
(82)
Vendu
518
Abonnés
17
Éléments
33572
Dernière vente
1 semaine de cela



Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Vous travaillez sur vos références ?

Créez des citations précises en APA, MLA et Harvard avec notre générateur de sources gratuit.

Vous travaillez sur vos références ?

Foire aux questions