In this section, we will write our very first Python program.
What is the first program about?
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.
- Type the following piece of code in the Trinket code editor.
- After typing, click the Run button on the top bar to see the output of your program.
- You should see
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!
- Press and hold the shift key with one finger, and press 9 with another finger while still holding the shift key to type
( and to type
) do the same thing but press 0 instead of 9.
- Make sure that the opening and closing quotes and parentheses match.
- Make sure there are no spaces in front of the print.
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.
I don’t see
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 |
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 |
|NameError: name ‘Print’ is not defined on line 1 in main.py||Make sure ‘p’ is lowercase in |
|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.
CLICK ON ‘MARK COMPLETE’ or ‘NEXT TOPIC’ at the top of the page to proceed.