Writing Your First Python Code
Scorri per mostrare il menu
1print('Hello, World!')
Step-by-Step Breakdown: Printing 'Hello, World!'
Let's look at the code sample:
print('Hello, World!')
Here's what each part of this line does:
-
print- This is a built-in Python function. It tells Python to display something on the screen.
-
Parentheses
()- Functions in Python use parentheses to enclose their arguments. Here, the parentheses surround the message you want to display.
-
Quotation marks
' '- In Python, anything inside single (
' ') or double (" ") quotes is considered a string—a sequence of characters (text).
- In Python, anything inside single (
-
'Hello, World!'- This is the string you want to display. You can replace it with any text you like.
When you run this code, Python will output:
Hello, World!
This is often the very first program written when learning a new programming language. It demonstrates how to use the print function to show information on the screen.
Now it's your turn! Try writing your own greeting message in Python. For example, you could print your name or a fun message. Type your code below using the print() function.
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 2
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Sezione 1. Capitolo 2