1.3 Your First Program: "Hello World!"

1.3 Your First Program: "Hello World!"

Tradition dictates: we write our first program that prints the "Hello World!" message and analyze the basic print() function.

In the programming world, there is an established tradition: the first program every beginner writes is "Hello World!". This simple program has the sole purpose of displaying the "Hello World!" message on the screen. In Python, implementing this tradition is incredibly easy and intuitive.
Try the following code in our live editor:
# This is your first program in Python!
print("Hello, World!")
print('Welcome to LearnPython.ai!')

Code Explanation

  • print(): This is a built-in function in Python. Its main purpose is to display messages or values on the screen (in the terminal).
  • "Hello, World!": This is a string, which is a sequence of characters. In Python, strings are enclosed in either single (') or double (") quotes.
  • # This is...: This line is a comment. Comments are ignored by the Python interpreter and are used to explain the code.

Explore More with AI

Use AI to generate new examples, delve deeper into theory, or get your questions answered.