Imparare Python da zero #04: eccezioni e controllo di flusso con il costrutto try-except-else-finally

Python mette a disposizione un meccanismo per la gestione delle eccezioni costituito dal costrutto try/except. Riprendiamo l’esempio della divisione tra due numeri inseriti in input dall’utente per vedere come funziona.

def divide(n1, n2):
	return n1/n2
	
n1 = int(input("Inserisci
(Read the full article)

Imparare Python da zero #03: input da tastiera, conversioni di tipo e funzione built-in “help”

Un’operazione ricorrente in buona parte dei programmi è la richiesta di inserimento di valori di input da parte dell’utente. In Python per realizzare questa funzionalità si utilizza la funzione built-in input() che legge i dati forniti dall’utente e li restituisce sotto forma di stringa. La funzione… (Read the full article)

Learning Python from scratch #02: modules, imports and __name__ variable

A Python program, unlike almost all other programming languages, has not a main method from which its execution starts. When running a Python module, the interpreter starts to execute the code that is on level 0 indentation.
Let’s create a simple module and try to run it from the command line:… (Read the full article)

Learning Python from scratch #00: Intro, interpreter, IDLE environment and modules

Python is an high-level object-oriented programming language, very powerful and flexible, often used as a scripting language. Python is an interpreted language so, before you can write and run Python programs, its interpreter must be installed on your machine. On Linux and Mac OS X machines it is … (Read the full article)

Imparare Python da zero #00: introduzione, l’interprete, l’ambiente IDLE ed i moduli

Python è un linguaggio di programmazione di alto livello orientato agli oggetti, molto potente e flessibile, spesso utilizzato anche come linguaggio di scripting. Python è un linguaggio interpretato per cui, prima di poter scrivere ed eseguire dei programmi Python occorre installare sulla propria… (Read the full article)