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.


Your First Program: Display your Name on the Screen

Go to Replit, create a pygame repl, and name it my_name


Write the following code in main.py:


Click on the green Run button at the top of the page


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.