Le funzioni che restituiscono un numero int (intero) si trovano tra quelle predefinite e nei moduli fractions, math, random, statistics, …
abs(), int(), len(), max(), min(), ord(), round(), pow(), sum()
math.ceil(), math.floor(), math.factorial(), math.gcd(), math.trunc()
random.randint()
statistics.mode()
Prova
- Copia il codice delle funzioni che ti interessano
- Assegna un valore alla/e variabile/i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
print("abs(", x, ") =" , abs(x) ) # Se x è intero... print("math.ceil(", x, ") =" , math.ceil(x) ) # x float, x Fraction print("math.floor(", x, ") =" , math.floor(x) ) # x float, x Fraction print("math.factorial(", n, ") =" , math.factorial(n) ) print("math.gcd(", a, ",", b, ") =" , math.gcd(a, b) ) # a,b interi print("int() =" , int() ) # 0 print("int(", s, ") =" , int(s) ) # s stringa print("int(", x, ") =" , int(x) ) # x float print("len(", z, ") =" , len(z) ) # z sequenza print("max(", x1, ",", x2, ") =" , max(x1, x2) ) # Se il max è intero... print("min(", x1, ",", x2, ") =" , min(x1, x2) ) # Se il min è intero... print("ord(", c, ") =" , ord(c) ) # Se c è un carattere... print("statistics.mode(z) =" , statistics.mode(z) ) # Se il primo valore della moda è intero... print("round(", x, ") =" , round(x) ) # x float, x Fraction print("pow(", x1, ",", x2, ") =" , pow(x1, x2) ) # Se x1, x2 sono interi... print("random.randint(", a, ",", b, ") =", random.randint(a, b) ) print("sum(", z") =" , sum(z) ) # Se gli elementi di z sono tutti interi... print("math.trunc(", x, ") =" , math.trunc(x) ) # x float, x Fraction |
Ancora…