Translations by Emanuele Rampichini
Emanuele Rampichini has submitted the following strings to this translation. Contributions are visually coded: currently used translations, unreviewed suggestions, rejected suggestions.
1 → 29 of 29 results | First • Previous • Next • Last |
1. |
Built-in Functions
|
|
2011-01-10 |
Le Funzioni Integrate
|
|
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.
|
|
2011-01-10 |
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.
|
|
3. |
abs
|
|
2011-01-10 |
abs
|
|
4. |
functions!abs
|
|
2011-01-10 |
functions!abs
|
|
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:
|
|
2011-01-10 |
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:
|
|
6. |
>>> print(abs(10))
10
>>> print(abs(-20.5))
20.5
|
|
2011-01-10 |
>>> print(abs(10))
10
>>> print(abs(-20.5))
20.5
|
|
7. |
bool
|
|
2011-01-10 |
bool
|
|
8. |
functions!bool
|
|
2011-01-10 |
functions!bool
|
|
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:
|
|
2011-01-10 |
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:
|
|
10. |
>>> print(bool(0))
False
>>> print(bool(1))
True
>>> print(bool(1123.23))
True
>>> print(bool(-500))
True
|
|
2011-01-10 |
>>> print(bool(0))
False
>>> print(bool(1))
True
>>> print(bool(1123.23))
True
>>> print(bool(-500))
True
|
|
11. |
For other values, None returns False while anything else returns True:
|
|
2011-01-10 |
Per quanto riguarda i valori diversi dai numeri, None restituisce False mentre qualsiasi altro valore restituisce True:
|
|
12. |
>>> print(bool(None))
False
>>> print(bool('a'))
True
|
|
2011-01-10 |
>>> print(bool(None))
False
>>> print(bool('a'))
True
|
|
13. |
cmp
|
|
2011-01-10 |
cmp
|
|
14. |
functions!cmp
|
|
2011-01-10 |
functions!cmp
|
|
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:
|
|
2011-01-10 |
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:
|
|
16. |
>>> print(cmp(1,2))
-1
|
|
2011-01-10 |
>>> print(cmp(1,2))
-1
|
|
17. |
And 2 is equal to 2:
|
|
2011-01-10 |
Mentre 2 è uguale a 2:
|
|
18. |
>>> print(cmp(2,2))
0
|
|
2011-01-10 |
>>> print(cmp(2,2))
0
|
|
19. |
But 2 is greater than 1:
|
|
2011-01-10 |
Ma 2 è più grande di 1:
|
|
20. |
>>> print(cmp(2,1))
1
|
|
2011-01-10 |
>>> print(cmp(2,1))
1
|
|
21. |
Compare doesn't only work with numbers. You can use other values, such as strings:
|
|
2011-01-10 |
La funzione per comparare non funziona soltanto con i numeri. Puoi utilizzare altri valori, come per esempio le stringhe:
|
|
22. |
>>> print(cmp('a','b'))
-1
>>> print(cmp('a','a'))
0
>>> print(cmp('b','a'))
1
|
|
2011-01-10 |
>>> print(cmp('a','b'))
-1
>>> print(cmp('a','a'))
0
>>> print(cmp('b','a'))
1
|
|
23. |
But do be careful with strings; the return value may not be exactly what you expect$\ldots$
|
|
2011-01-10 |
Ma stai molto attento con le stringhe; il valore restituito potrebbe non essere esattamente quello che ti aspetti$\ldots$
|
|
24. |
>>> print(cmp('a','A'))
1
>>> print(cmp('A','a'))
-1
|
|
2011-01-10 |
>>> print(cmp('a','A'))
1
>>> print(cmp('A','a'))
-1
|
|
25. |
A lower-case 'a' is actually greater than an upper-case 'A'. Of course$\ldots$
|
|
2011-01-10 |
Una 'a' minuscola in realtà è più grande di una 'A'. Naturalmente$\ldots$
|
|
26. |
>>> print(cmp('aaa','aaaa'))
-1
>>> print(cmp('aaaa','aaa'))
1
|
|
2011-01-10 |
>>> print(cmp('aaa','aaaa'))
-1
>>> print(cmp('aaaa','aaa'))
1
|
|
27. |
$\ldots$3 letter a's (aaa) are less than 4 letter a's (aaaa).
|
|
2011-01-10 |
\ldots$ 3 lettere 'a' (aaa) sono più piccole di 4 lettere 'a' (aaaa).
|
|
28. |
dir
|
|
2011-01-10 |
dir
|
|
29. |
functions!dir
|
|
2011-01-10 |
functions!dir
|