|
11.
|
|
|
For other values, None returns False while anything else returns True:
|
|
|
type: Plain text
|
|
|
|
Per quanto riguarda i valori diversi dai numeri, None restituisce False mentre qualsiasi altro valore restituisce True:
|
|
Translated by
Emanuele Rampichini
|
|
Reviewed by
Martino Barbon
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:42
|
|
12.
|
|
|
>>> print(bool(None)) ![](/@@/translation-newline)
False ![](/@@/translation-newline)
>>> print(bool('a')) ![](/@@/translation-newline)
True
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
represents a space character.
Enter a space in the equivalent position in the translation.
|
|
|
|
>>> print(bool(None)) ![](/@@/translation-newline)
False ![](/@@/translation-newline)
>>> print(bool('a')) ![](/@@/translation-newline)
True
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:49
|
|
13.
|
|
|
cmp
|
|
|
type: subsection{#2}
|
|
|
|
cmp
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:53
|
|
14.
|
|
|
functions!cmp
|
|
|
type: index{#1}
|
|
|
|
functions!cmp
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:53
|
|
15.
|
|
|
The \textbf{cmp} function compares two values and returns a negative number if the first value is less than the second; returns 0 if the first value is equal to the second; and returns a positive number if the first value is greater than the second. For example, 1 is less than 2:
|
|
|
type: Plain text
|
|
|
|
La funzione \textbf{cmp} compara due valori e restituisce un numero negativo se il primo valore è più piccolo del secondo, restituisce 0 se i due valori sono uguali e restituisce un numero positivo se il primo valore è più grande del secondo. Per esempio, 1 è più piccolo di 2:
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:55
|
|
16.
|
|
|
>>> print(cmp(1,2)) ![](/@@/translation-newline)
-1
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
|
>>> print(cmp(1,2)) ![](/@@/translation-newline)
-1
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:60
|
|
17.
|
|
|
And 2 is equal to 2:
|
|
|
type: Plain text
|
|
|
|
Mentre 2 è uguale a 2:
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:65
|
|
18.
|
|
|
>>> print(cmp(2,2)) ![](/@@/translation-newline)
0
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
|
>>> print(cmp(2,2)) ![](/@@/translation-newline)
0
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:70
|
|
19.
|
|
|
But 2 is greater than 1:
|
|
|
type: Plain text
|
|
|
|
Ma 2 è più grande di 1:
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:75
|
|
20.
|
|
|
>>> print(cmp(2,1)) ![](/@@/translation-newline)
1
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
|
>>> print(cmp(2,1)) ![](/@@/translation-newline)
1
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:80
|