|
2.
|
|
|
Python has a number of built-in functions---functions that can be used without needing to \textbf{import} them first. Some of the available built-in functions are listed below.
|
|
|
type: Plain text
|
|
|
|
Python ha una collezione di funzione integrate---funzioni che possono essere utilizzate senza essere importate con la parola chiave \textbf{import}. Puoi trovare alcune delle funzioni integrate nella seguente lista.
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:10
|
|
3.
|
|
|
abs
|
|
|
type: subsection{#2}
|
|
|
|
abs
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:12
|
|
4.
|
|
|
functions!abs
|
|
|
type: index{#1}
|
|
|
|
functions!abs
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:12
|
|
5.
|
|
|
The \textbf{abs} function returns the absolute value of a number. An absolute value is a number that is not negative. So the absolute value of 10 is 10, and the absolute value of -20.5 is 20.5. For example:
|
|
|
type: Plain text
|
|
|
|
La funzione \textbf{abs} restituisce il valore assoluto di un numero. Il valore assoluto di un numero è lo stesso numero non negativo. Il valore assoluto di 10 è 10, il valore assoluto di -20.5 è 20.5. Per esempio:
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:14
|
|
6.
|
|
|
>>> print(abs(10)) ![](/@@/translation-newline)
10 ![](/@@/translation-newline)
>>> print(abs(-20.5)) ![](/@@/translation-newline)
20.5
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
|
>>> print(abs(10)) ![](/@@/translation-newline)
10 ![](/@@/translation-newline)
>>> print(abs(-20.5)) ![](/@@/translation-newline)
20.5
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:21
|
|
7.
|
|
|
bool
|
|
|
type: subsection{#2}
|
|
|
|
bool
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:25
|
|
8.
|
|
|
functions!bool
|
|
|
type: index{#1}
|
|
|
|
functions!bool
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:25
|
|
9.
|
|
|
The \textbf{bool} function returns either True or False based on the value passed as its parameter. For numbers, 0 returns False, while any other number returns True:
|
|
|
type: Plain text
|
|
|
|
La funzione \textbf{bool} restituisce True (vero) o False (falso) in base al valore passato come parametro. Per quanto riguarda i numeri, 0 restituisce False, mentre tutti gli altri numeri restituiscono True:
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:27
|
|
10.
|
|
|
>>> print(bool(0)) ![](/@@/translation-newline)
False ![](/@@/translation-newline)
>>> print(bool(1)) ![](/@@/translation-newline)
True ![](/@@/translation-newline)
>>> print(bool(1123.23)) ![](/@@/translation-newline)
True ![](/@@/translation-newline)
>>> print(bool(-500)) ![](/@@/translation-newline)
True
|
|
|
type: verbatim
|
|
|
represents a line break.
Start a new line in the equivalent position in the translation.
|
|
|
|
>>> print(bool(0)) ![](/@@/translation-newline)
False ![](/@@/translation-newline)
>>> print(bool(1)) ![](/@@/translation-newline)
True ![](/@@/translation-newline)
>>> print(bool(1123.23)) ![](/@@/translation-newline)
True ![](/@@/translation-newline)
>>> print(bool(-500)) ![](/@@/translation-newline)
True
|
|
Translated and reviewed by
Emanuele Rampichini
|
|
|
|
Located in
./ORIGINAL/appendixb.tex:38
|
|
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
|