First Steps
This will guide you through writing your first program in Python 🐍.
DEFINITION
Program: A program is a list of instructions written by humans which tell a computer how to do an action.
Go ahead and copy the following line into the Python editor:
print('Hello World')Click the Run button. This will start the program. What is the outcome?.
Congratulations, you have built and run your very first Python program! 🎉 This program draws words onto the screen!
TRY THIS
We can change the code to print other words onto the screen. Change the code to print out your name.
We need to use quotation marks surrounding text in our program. They are needed whenever we work with text. The quotation marks tell us where the text begins and where it ends. But they aren't part of the text, so they don't get printed.
Printing Numbers
We learned how to print words and text to the screen. What about numbers? Copy the line of code below and run it. What is the result?
print(2)Questions
- What happens if you forget to tell the computer what to print. Try running
print()and see what happens.
Recap
print('...')will print the text inside the quotes to the screen when the program is runprint(<number>)will print the number to the screen when the program is run