What is Python?

Python is a programming langugage. Basically, a way that we tell the computer what to do! Python can be used to create a variety of different programs including games.


How to Open the Python Shell on your Chromebook

Click on the IDLE3 icon on the shelf. It's the icon that looks like a penguin.

Your First Program: Display your Name on the Screen

Open the Python Shell. Then, From the File menu, choose New File. This will open a new window where we will write our code


Write the following code in the window:


From the Run menu, click Run Module, or just press the F5 key


You will then be asked to save the file. Click OK.

Then, type your name in the box and then click Save

The output should look something like:



If you get an error or something different:

  • It's okay! Mistakes happen
  • Does the code match the example exactly?
  • Did you add 4 spaces or a tab before screen.draw.text("Your Name", topleft=(10, 10))
  • Have I typed pgzrun correctly?
  • Make the neessary changes to your code and run it again
  • Go back to the File menu and click Save. Then go to the Run menu and click Run Module.


Challenge

Play around with the code! See what happens when you change the text "Your Name" and the numbers (10,10). Also try the following:

  • Change the numbers from (10,10) to (100,100). What happened? What does that tell you about what the code does?
  • Change the color of your text. Add the following code: color="blue" after you set topleft. Remeber to add a comma before you add the color code!


Copyright © KX Technology Group, LLC. All Rights Reserved.