CodeGym /Courses /Python SELF EN /Commands and First Program

Commands and First Program

Python SELF EN
Level 1, Lesson 1
Available

1. Commands

Program — it's a set (or list) of commands. First, the first command gets executed, then the second, the third, and so on. When all the commands are done, the program finishes.

What kind of commands can be on the list depends on who is executing them: what commands the executor knows (and understands). You can tell a dog 🐕 to "Sit", "Speak", a cat 🐈 — "Shoo!", a person — "Stop! I'll shoot!", and a robot 🔧 — "Work! Work, you robomother!"

Programs written in Python are executed by py.exe (Python Interpreter). Python Interpreter — is a special program that knows how to execute code written in Python.

Its list of commands is pretty extensive. For example, this command can display "Robot is a friend of humans" on the screen:


print("Robot is a friend of humans")

But we're not diving straight into commands, we'll start with a couple of simple principles. Knowing a few principles can replace knowing a lot of facts.

2. Basic Python Principles

First principle: In Python, it's customary to write each command on a new line.

Suppose we want to print "Robot is a friend of humans" to the screen 3 times. Here's how the program code would look:


print("Robot is a friend of humans")
print("Robot is a friend of humans")
print("Robot is a friend of humans")

Second principle: The number of spaces (indentation) at the beginning of a line is super important.

This is a unique feature of Python. Commands that follow each other must have the same amount of indentation (spaces) at the start. This code won’t work:


print("Robot is a friend of humans")
   print("Robot is a friend of humans")
print("Robot is a friend of humans")

Third principle: Commands are grouped using indentation from the left.

If several commands have the same amount of indentation on the left, they're considered part of the same block. Example:


for name in ["Masha","Katya","Anya"]:
     print("Robot is a friend of humans")
     print(f"{name} is a friend of robots")

You’ll learn more about code blocks in the upcoming lectures.

3. First Program

It's time to write your first program. Why put off such a good thing for later?

Usually, the first program is all about displaying some basic text on the screen, like Hello, World!. But honestly, that's way too basic. Your first program should be something you'll remember forever. Come up with a bright, pompous, and memorable phrase.

If you can’t think of anything, here are some suggestions:

  • “It is inevitable. It is your destiny.”
  • “Do what must be done, Lord Vader. Do not hesitate. Show no mercy.”
  • “The dark side of the Force is a pathway to many abilities some consider to be unnatural.”

But before we jump into writing the first program, let me show you where you’ll actually be coding.

Comments (9)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
kim jisoo Level 4, karachi, Pakistan
9 March 2026
print("Always follow your dreams")
Anonymous #11709018 Level 1, Sambalpur, India
20 October 2025
Excited for the new journey 😃
David Solomon Level 1, Nigeria
17 September 2025
am getting out of my mind right now😎
John Kurt Tristan Camata Level 1, Philippines
17 September 2025
😍
SUMIT DAS Level 3, CodeGym University in India, India
1 September 2025
Thank you
kim jisoo Level 4, karachi, Pakistan
22 June 2025
ohhhh thats an amazing intro to python
Anonymous #11662906 Level 1, Nagpur, India
19 June 2025
this is coding I am coding let's coding
ogbe B. Lawson Level 2, Nigeria
8 May 2025
I've heard so much about codegym, happy to be here.
M Arshad Arshad Level 1, Pakistan
18 April 2025
i am very exciting