Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!

This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join 11 million other learners and get started learning Python for data science today!

Good news! You can save 25% off your Datacamp annual subscription with the code LEARNPYTHON23ALE25 - Click here to redeem your discount

Ciao, Mondo!


Python è un linguaggio molto semplice, e ha una sintassi molto diretta. Incoraggia i programmatori a programmare senza codice di base (pronto). La direttiva più semplice in Python è la direttiva "print" - che semplicemente stampa una linea (e include anche un a capo, a differenza del C).

Ci sono due principali versioni di Python, Python 2 e Python 3. Python 2 e 3 sono piuttosto diversi. Questo tutorial utilizza Python 3, perché è semanticamente più corretto e supporta funzionalità più recenti.

Ad esempio, una differenza tra Python 2 e 3 è l'istruzione print. In Python 2, l'istruzione "print" non è una funzione, e quindi viene invocata senza parentesi. Tuttavia, in Python 3, è una funzione e deve essere invocata con le parentesi.

Per stampare una stringa in Python 3, basta scrivere:

Indentazione

Python utilizza l'indentazione per i blocchi, invece delle parentesi graffe. Sono supportati sia i tab che gli spazi, ma l'indentazione standard richiede che il codice Python standard utilizzi quattro spazi. Ad esempio:

Esercizio

Usa la funzione "print" per stampare la linea "Hello, World!".

This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!

Next Tutorial Take the Test
Copyright © learnpython.org. Read our Terms of Use and Privacy Policy