Home

Write a Simple Program in Python

|
|  Updated:  
2023-08-10 16:10:30
Python Essentials For Dummies
Explore Book
Buy On Amazon
Tradition dictates that Hello World! be the first program that you write when you're learning a new programming language like Python. You're following in the footsteps of many great programmers when you create this project.

To create your Hello World! program, follow these steps:

  1. Open your Start menu and choose Python (command line).

    You should get a prompt that looks like >>>.

    At the moment, you're doing everything in interactive mode in the Python interpreter. That's where the >>> comes in. Python shows you >>> when you're supposed to type something.

  2. At the prompt, type the following. Use a single quote at the start and the end — it's beside the Enter key:

    print('Hello World!')
  3. Press the Enter key.

    Python runs the code you typed.

You see the output shown in Figure 1. Congratulations — you've written your first program. Welcome to the Python-programmers-in-training club.

<b>Figure </b><b>1:</b> Your Hello World! program is ready for more instructions. Figure 1: Your Hello World! program is ready for more instructions.

If you don't see what's in Figure 1, check that you typed in the text from Step 2 exactly as it's written:
  • Check that the parentheses and single quotes are in the right places.

  • Check that for each opening parenthesis there is a closing parenthesis. (Otherwise, you're left hanging.

  • Check that for each opening quote there's a closing quote.

Programming languages have their own grammar and punctuation rules. These rules are the language's syntax. Humans, can work most stuff out even if perfect not you're is grammar (See? You figured out what that sentence was trying to say), but Python pretty much freaks out if you get the syntax wrong.

About This Article

This article is from the book: 

About the book author:

Brendan Scott is a dad who loves Python and wants kids to get some of its magic too. He started pythonforkids.brendanscott.com to help teach his oldest child to code. He maintains it to help other young people learn Python.