0% found this document useful (0 votes)
23 views

Year 9-Lesson 6-Intro To Python Programming-1

Uploaded by

aaroush199
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Year 9-Lesson 6-Intro To Python Programming-1

Uploaded by

aaroush199
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Year 9 Unit 1

Intro to Python programming


ICT
Lesson 6
Putting it all together
Starter activity
Guess my lucky number: multiple attempts

lucky = 13 1. Pick a lucky number .

print("Can you guess my lucky number?") 2. Ask the user to guess .


guess = int(input())
if guess == lucky: 3. Display feedback to the user .
print("Amazing, you guessed it")
else:
print("Sorry, it’s not", guess)
print("Nice playing with you") 4. Say goodbye .

Which of these program segments will need to be repeated if the user


is allowed multiple guesses?
Starter activity
Guess my lucky number: multiple attempts

lucky = 13 ↺
Pick a lucky number
print("Can you guess my lucky number?") Ask the user to guess .
guess = int(input())
if guess == lucky: Display feedback to the user .
print("Amazing, you guessed it")
else:
print("Sorry, it’s not", guess)
print("Nice playing with you") Say goodbye

Which of these program segments will need to be repeated if the user


is allowed multiple guesses?
Outcomes
In this lesson, you will...
● Use three control structures (sequence, selection, and iteration) to build a more
complex program
● Use Boolean variables, operators, and expressions
● Take a quiz, to assess what you have learnt
Activity 1
Lucky number revisited

Use pair programming .


Driver
Control the keyboard and mouse.
Navigator
Provide support and instructions.
Alternate between roles.
Activity 1
Guess my lucky number: multiple attempts
lucky = 13 ↺
Pick a lucky number
print("Can you guess my lucky number?") Ask the user to guess .
guess = int(input())
if guess == lucky: Display feedback to the user .
print("Amazing, you guessed it")
else:
print("Sorry, it’s not", guess)
print("Nice playing with you") Say goodbye

Live coding (ncce.io/py-lucky-6)


Activity 1
Guess my lucky number: run your program
lucky = 13 Faced with an error? Here are some things
that you will need to check:
guessed = False ◻ Is the F in False capitalised?
while guessed == False:

◻ Does the condition use == to check if
print("Can you guess my lucky number?") the value of guessed is False?
guess = int(input()) ◻ Have you remembered the colon : after
the condition in while?
if guess == lucky: ◻ Have you used indentation, to
print("Amazing, you guessed it") indicate which statements belong to
else: the while block?
print("Sorry, it’s not", guess)
Tip: Press the ‘Stop’ button or try Control+C
print("Nice playing with you")
to terminate your program.
Activity 2
Lucky number revisited

Start from your current program.


Complete the tasks in your worksheet to
build a more complete ‘Guess the number’
game.
Activity 2
Logical operators in Python

You can use these operators to combine Examples


logical expressions.

not negation not a == 1


and conjunction b > 10 and c <= d
or disjunction e == 10 or f != 1

Expressions formed using these operators


evaluate to either True or False.
Assessment
Summative assessment

Exam Conditions
You are under exam conditions:
- Keep silent
- Keep your eyes on your own paper/ computer
- Do not distract
- Sit still and do not turn around

Failure to comply with these rules will result in:


- Disqualification - your paper will be cancelled
- Parents contacted

10
Summary
Unit takeaways

On a sticky note, write:


One thing that impressed you
One thing that you learnt
(and that you’ll remember)
And one thing that you didn’t really enjoy
Summary
In this lesson, you...
Used three control structures (sequence, selection, and iteration) to build a more
complex program

Used Boolean variables, operators, and expressions

Took a quiz, to assess what you have learnt


Summary
In this unit, you...
Explored what basic programming structures look like in Python

Built your first Python programs

You might also like