In this section, we will write our very first Python program.
Learning to code is a lot like learning a new spoken language. When you learn a new language, one of the first words you learn are greetings like Hola, Hello, Ni Hao, or Namaste!
So for our first program, we will make the computer display a greeting on the screen.
print('hello world')
hello world
printed in the output box. See the video below on how to do all the above steps.
Now, it’s your turn. Please type the code in the Trinket box below and run it!
Do not copy-paste; It’s much more fun to type your program. Try it!
(
and to type )
do the same thing but press 0 instead of 9. If you see hello world
in the output window, then congratulations!! You just coded your very first Python program.
This program may not look all that fancy-schmancy, but this is an important milestone in your coding journey.
hello world
in the output window after clicking Run. Instead, I see an Error. 🙁Awesome!! You, my friend, are one step ahead in the course already. Congratulations!!
What you see? | What you do? |
---|---|
SyntaxError: EOF in multi-line statement on line 2 ^ in main.py | Check for missing parentheses at the end. |
SyntaxError: bad input on line 1 in main.py | 1. Check for space before print .2. Missing parentheses or quote at the start. |
SyntaxError: bad token on line 1 in main.py. | 1. Missing quote at the end. 2. Quote mismatch (using double quotes instead of a single quote). |
NameError: name ‘prnt’ is not defined on line 1 in main.py | Check the spelling of command print |
NameError: name ‘Print’ is not defined on line 1 in main.py | Make sure ‘p’ is lowercase in print |
IndentationError: unexpected indent | Make sure there is no space before print. |
No error or output is printed | Make sure you have print function before the parentheses. |
Error is not listed above | Email us your error and keep calm. We got you covered! |
Don’t fret if the error message did not make any sense. We will come back to it in the upcoming lessons.