Writing Your First Python Code
Swipe to show 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.
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 2
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
SectionΒ 1. ChapterΒ 2