
Python- Getting to know the language
Presentation
•
English
•
8th Grade
•
Easy
Vasantha Ponnen
Used 8+ times
FREE Resource
23 Slides • 5 Questions
1
Lesson 1: Getting to know the language
Year 8 – Intro to Python programming
2
3
Starter activity
Can you follow these instructions?
Align the two strips
at one end.
Cut the longer strip
where the shorter
strip ends.
Discard the part that
you have cut off that is
the same length as the
shorter strip.
Repeat
to
until the strips are
equal in length.
Measure that length
and report it — it’s
the required result.
a
b
c
a
c
You have two strips of paper. One is X cm long, the other is Y cm long.
4
Unit objectives
●Used a block-based programming
language (Scratch) to create
programs that involved:
○Variables, operators, and
expressions
○Sequence, selection, and iteration
○Subroutines
○Lists
In the previous units, you...
In this unit, you will...
●Use a text-based programming
language (Python) to build on
these concepts and extend
them
print("Hello Python!")
5
Objectives
I can explain keywords in python in my own
words
- Program, Algorithm, Syntax
I can write my first function in python
I can create my own function using examples
In this lesson, you will...
6
Activity 1
Algorithms
An algorithm is a set of precise
instructions, expressed in some sort
of language (e.g. textual, visual).
Understanding the language is
necessary in order to execute the
instructions.
Executing these instructions is meant
to solve a problem.
7
Activity 1
Programs
A program is a set of precise
instructions, expressed in a
programming language.
Translating the programming
language is necessary for a machine
to be able to execute the
instructions.
8
Activity 1
Python programs
To execute a Python program, you
need a Python interpreter.
This is a program that translates and
executes your Python program.
The Python interpreter doesn’t necessarily run
on your computer.
9
Activity 1
Syntax
All languages have rules for syntax,
i.e. how sentences can be assembled.
Speech or text in a language must
follow its syntax.
Humans can infer meaning even in
cases when syntax rules are violated.
For example, “tonigth see you”, instead of “see
you tonight”, will probably be understood.
All programming languages have
rules for syntax, i.e. how statements
can be assembled.
Programs written in a programming
language must follow its syntax.
Programs with syntax errors cannot
be translated and executed.
10
Activity 1
Syntax
In Scratch, syntax errors are not
possible: rules are enforced by the
blocks and the way they fit together.
All programming languages have
rules for syntax, i.e. how statements
can be assembled.
Programs written in a programming
language must follow its syntax.
Programs with syntax errors cannot
be translated and executed.
You can still make logical errors !
That’s when your program doesn’t
work the way it should.
11
Syntax
Activity 1
In Python, you can (and you will)
make syntax errors. You will need to
follow the syntax rules.
All programming languages have
rules for syntax, i.e. how statements
can be assembled.
Programs written in a programming
language must follow its syntax.
Programs with syntax errors cannot
be translated and executed.
Syntax errors can be frustrating when you start
learning a text-based programming language.
if remaining < 10:
print("We are getting there")
else:
print("Still some way to go")
12
Syntax
Activity 1
SyntaxError: invalid syntax
SyntaxError: Missing parentheses in
call to 'print'.
SyntaxError: EOL while scanning string
literal
Has this happened to
YOU?
Don’t be overwhelmed by these
errors. They are here to discourage
the faint-hearted. You can fix them!
13
Your first steps in Python
Activity 2
Every time you learn a new
programming language,
it’s a tradition to get your first
program to say “hello”.
print("Hello world!")
14
Multiple Choice
An algorithm is a set of precise instructions designed to solve a problem.
True
False
15
Activity 2
Your first steps in Python
Complete the first task in your
worksheet to create your own ‘Hello
world’ program.
16
print("Hello world!")
Your first steps in Python: commentary
Activity 2
Have you used (single or double) quotation
marks around the message to be displayed?
Have you used (opening and closing) round
brackets around the message to be displayed?
Checklist:
Have you spelt print correctly?
Python is case-sensitive: using capitals makes a
difference.
✔
✔
✔
17
print("Hello world!")
Your first steps in Python: commentary
Activity 2
You will need the print function:
when your program must display text, numbers,
or the values of variables and expressions.
18
Multiple Choice
What will happen when this code is run?
Nothing there is an error on line 2
It will print the following:
Hello World!
Oh, you are a wally
It will print the following:
"Hello World!"
Then wait for next instruction
Nothing, there is no instruction given to the user.
19
Multiple Choice
What print(" ") function does?
Prints values in the program
Prints whats inside the quotation
Prints a copy of the code
Pints a pdf throught a printer
20
Activity 2
Your first steps in Python
Complete the second task in your
worksheet to greet the user by
name.
21
Multiple Choice
Python is the fastest growing programming language:
True
False
22
user = "Claude"
print("Hello", user)
Your first steps in Python: commentary
Activity 2
user is a variable, i.e. a name for a value.
The variable user currently refers to the value
"Claude".
The quotation marks around the value show the
type of the value: it is a string (a piece of text).
You will need an assignment statement:
when your program must use a name
(an identifier) to keep track of a value.
23
Activity 2
Your first steps in Python
Complete the third task in your
worksheet.
24
user = "Claude"
print("Hello", user)
lucky = 13
print("My lucky number is", lucky)
Your first steps in Python: commentary
Activity 2
lucky is another variable.
It is assigned an integer value.
It is useful to sketch variables and their
corresponding values, as they change
during program execution.
user
"Claude"
lucky
13
user is a variable.
It is assigned a string value.
25
Activity 2
Your first steps in Python
Complete the final task in your
worksheet, to make your program
receive input from the user.
26
print("What’s your name?")
user = input()
print("Hello", user)
Your first steps in Python: commentary
Activity 2
The text typed by the user is assigned to the
user variable.
When input is invoked, the program pauses,
waiting for keyboard input.
We can refer to the value of user in the
program without knowing what it will be.
You will need the input function:
when your program must receive keyboard
input from the user.
27
print("Best film ever?")
film = input()
print(film, "is my favourite too!")
Python recap
Activity 3
●Display a message for the user
on the screen
Locate the fragment(s) of code that:
●Retrieve what the user types on
the keyboard
●Assign a value to a variable
28
Multiple Choice
Text to be output to the screen should be enclosed by " "
True
False
Lesson 1: Getting to know the language
Year 8 – Intro to Python programming
Show answer
Auto Play
Slide 1 / 28
SLIDE
Similar Resources on Wayground
22 questions
Literary Devices (aka Figurative Language)
Presentation
•
7th - 8th Grade
21 questions
Storyboard
Presentation
•
8th Grade
20 questions
Characterization
Presentation
•
7th - 8th Grade
21 questions
Harriet Tubman: Conductor on the Underground Railroad
Presentation
•
8th Grade
20 questions
Imagery
Presentation
•
8th Grade
20 questions
Prohibition, Obligation and Suggestion Lesson
Presentation
•
8th Grade
19 questions
Diary of Anne Frank Act 1 Conflict & Drama Elements
Presentation
•
8th Grade
21 questions
The Outsiders Pre-Reading
Presentation
•
7th - 8th Grade
Popular Resources on Wayground
10 questions
How much do you know about our Portrait of an Eagle?
Quiz
•
10th Grade
10 questions
Fast Food Slogans
Quiz
•
6th - 8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
Discover more resources for English
25 questions
Making Inferences
Quiz
•
6th - 8th Grade
20 questions
Figurative Language Review
Quiz
•
8th Grade
30 questions
Central Idea practice Grade 7-8
Quiz
•
6th - 8th Grade
12 questions
Final Figurative Language Review
Presentation
•
6th - 8th Grade
20 questions
Sentences, Fragments, and Run-ons
Quiz
•
8th Grade
20 questions
TEXTUAL EVIDENCE & INFERENCES
Quiz
•
6th - 8th Grade
11 questions
Objective Summary Review
Quiz
•
6th - 8th Grade
17 questions
Plot
Quiz
•
8th Grade