Introduction to Python: Lesson 1
Introduction
What is Python
Python is a computer programming language that is straightforward and fairly easy to learn.
During this unit you will start out learning how to write a simple program of just a couple of words. As the weeks progress you will eventually create your own chat bot with whom you can hold a conversation.
1a. Starting Off
Watch this:
- Watch this video to find out how to open Python. You will need headphones
Do this:
- Create a folder in your area, call it 'Python Year 7'
Do this:
| Open and save this document into your area |
Do this:
|
Try this:
- Open Python on your computer
- Make sure that you have both the Shell and the program window open
Write this:
- Go to your worksheet and answer question 1b
Create this:
- Go to your worksheet and answer question 1b
Check your answer:
- Check you answer
- Check
Discuss this:
- Open Python on your computer
- Make sure that you have both the Shell and the program window open
Test Yourself:
- Open Python on your computer
- Make sure that you have both the Shell and the program window open
Read this:
- Open Python on your computer
- Make sure that you have both the Shell and the program window open
Remember this:
- In Python, you can use either single or double speech marks, but if you start a line of code with a single speech mark then you must finish with the same. You cannot mix them.
Homework:
- With the exception of the gold star challenges, complete everything else for homework
Information:
- Look at your code. Do you notice that the two variables are joined with a + symbol? The + tells python to join or 'concatenate' the two variables together.
Code this:
- In the program window type the following code EXACTLY as shown:
print ("Hello World")
- Press F5 to run your program. Save it to your folder with a sensible name.
- Did you see Hello World appear in the Shell?
- If you didn't then go back and look at your code and make sure that it looks exactly like the code written on this page.
- Press F5 to run your program.
- What happened?
Save this:
- Save your worksheet to your area
- Save and close any Python programs that you still have open
Extension Task:
- Start a new project.
- Use the skills that you have learned to set up a conversation between two new sprites
- Add in suitable timings, pauses, costume changes, sounds etc.
Gold:
- Gold
- Check
Silver:
- Gold
- Check
Bronze:
- Gold
- Check
1c. Testing upper and lower case
Code this:
- In the program window, change the code to look like this (notice the capital P):
Print ('Hello World')
- Press F5 to save and run your program
- What happened?
- On your worksheet explain what caused the error message
| Error message | What you have done wrong |
|---|---|
‘Print’ is not defined |
Used a capital P instead of a lower case p |
Invalid syntax |
No speech marks used Missing speech marks on one side |
EOL while scanning string literal |
Single speech mark on one side, double on other |
Missing parentheses in call to ‘print’ |
No brackets used Closing bracket used but no opening bracket |
Unexpected EOF while parsing |
Opening bracket used but not closing |
Error:
- If you got an error message go back to your code and check it carefully:
- did you use an opening and closing bracket?
- did you use speech marks at the beginning and end of the value?
- did you use a capital P for print instead of a small p?
- did you use a capital F for the first 'forename' and a lower case f for the second?
- Did it work? If not, try again.
-
Hyperlinks!
Do this:
- Create your own bitmap graphic of a space invader sprite.
- Use the grid underneath the timer to create your image.
- You have 5 minutes to complete this activity. Start the timer now by pressing 'Play'.
| Hours | Minutes | Seconds | |||||
❯ |
❯ |
❯ |
❯ |
❯ |
|||
|
|
|
: |
|
|
: |
|
|
❯ |
❯ |
❯ |
❯ |
❯ |
❯ |
||
THIS IS THE PICK AND PLACE QUIZ
this is the flash card
this is the text game
Think about this:
- Open Python on your computer
- Make sure that you have both the Shell and the program window open