Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Writing Your First Python Code | Getting Started with Python
Introduction to Python

bookWriting Your First Python Code

Swipe um das Menü anzuzeigen

1
print('Hello, World!')
copy

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:

  1. print

    • This is a built-in Python function. It tells Python to display something on the screen.
  2. Parentheses ()

    • Functions in Python use parentheses to enclose their arguments. Here, the parentheses surround the message you want to display.
  3. Quotation marks ' '

    • In Python, anything inside single (' ') or double (" ") quotes is considered a string—a sequence of characters (text).
  4. '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.

question mark

Which of the following is the correct way to print 'Hello, World!' in Python?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 2

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Abschnitt 1. Kapitel 2
some-alt