Python Hello World: Difference between revisions

From OpenCourse
(Created page with "In this lesson, we will create a 'Hello World' program in Python. == Python course == This lesson is part of the Python course. Go to the next lesson. Go to the previous lesson. Go back to the course overview. Category:Python")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
In this lesson, we will create a 'Hello World' program in Python.
In this lesson, we will create a 'Hello World' program in Python.
== Lesson content ==
In this lesson, we will learn:
* What hello world programs are
* Coding a hello world program in Python
* How our code works
* Running Python code through the terminal
* Program output
== Hello world programs ==
A '<nowiki/>'''hello world'''' program is a simple program that prints the string '''"Hello world"''' to the console.
A string is another word for text.
The console is the text-based window you see when opening a terminal or command prompt.
=== Why use a hello world program? ===
Hello world programs are used because they are very simple to write.
They are a good introduction to programming, as they are an easy way to learn the basic syntax (grammar) of the language.
== Coding ==
Now let's get coding!
In this chapter, we will open our program in a text editor, and write our first line of code!
=== Opening the file ===
First, we need to open up our program.
If you are using a code editor, such as VS Codium, open your project folder using the 'Open Folder' feature.
Otherwise, simply open '''hello.py''' in a normal text editor using the 'Open' button.
=== Writing the code ===
Inside '''hello.py''', write the following code:
'''print("Hello world")'''
We will go over how this code works in the next chapter.
== How it works ==
Our program contains 3 main tokens:
* print
* ()
* "Hello world"
== The print function ==
In our program, we call the '''print''' function.


== Python course ==
== Python course ==

Latest revision as of 15:47, 2 August 2023

In this lesson, we will create a 'Hello World' program in Python.

Lesson content[edit | edit source]

In this lesson, we will learn:

  • What hello world programs are
  • Coding a hello world program in Python
  • How our code works
  • Running Python code through the terminal
  • Program output

Hello world programs[edit | edit source]

A 'hello world' program is a simple program that prints the string "Hello world" to the console.

A string is another word for text.

The console is the text-based window you see when opening a terminal or command prompt.

Why use a hello world program?[edit | edit source]

Hello world programs are used because they are very simple to write.

They are a good introduction to programming, as they are an easy way to learn the basic syntax (grammar) of the language.

Coding[edit | edit source]

Now let's get coding!

In this chapter, we will open our program in a text editor, and write our first line of code!

Opening the file[edit | edit source]

First, we need to open up our program.

If you are using a code editor, such as VS Codium, open your project folder using the 'Open Folder' feature.

Otherwise, simply open hello.py in a normal text editor using the 'Open' button.

Writing the code[edit | edit source]

Inside hello.py, write the following code:

print("Hello world")

We will go over how this code works in the next chapter.

How it works[edit | edit source]

Our program contains 3 main tokens:

  • print
  • ()
  • "Hello world"

The print function[edit | edit source]

In our program, we call the print function.

Python course[edit | edit source]

This lesson is part of the Python course.

Go to the next lesson.

Go to the previous lesson.

Go back to the course overview.