|||
Accessibility Settings

Y10 AU – CT3 – Number Data and Conditional Sequences

Copy this title into a new OneNote document:

Y10 AU – CT3 – Number Data and Conditional Sequences

Complete this table and copy it into the OneNote document:

⏱️ Do It Now:
Answer the following questions

(1) Describe the difference between real and integer data

(2) Give the only two values a boolean variable can have

(3) Describe the difference between a variable and a constant

(4) Explain why casting needs to be done to inputs that contain numbers

(5) Explain why variables need to be initialised at the beginning of a program

🎯 Objectives:

(1) We will be able to identify the components of a conditional sequence

(2) We will be able to select and apply relevant relational operators to a conditional sequence

(3) We will be able to create branched conditional sequences

🔮 Predict

Look at the code below

We will use the Mini Whiteboard app to answer a series of targeted questions about it.

#---------------------- Global Variables ----------------------------

num1 = 0
num2 = 0

#---------------------- Main Program --------------------------------

num1 = input("Enter Number 1: ")

num2 = input("Enter Number 2: ")

if num1 > num2:
    print("Number 1 is the larger than Number 2")
else:
    print("Number 1 is not larger than Number 2")

Questions:

(1) What is missing from this program, and why should it have been used?

(2) Describe what this program is supposed to do

(3) How do we know we have reached the end of a condition?

(4) What is the purpose of > ?

(5) Why do we need a separate IF and ELSE?

———————————————————————————————————————————————–

(6) Describe how you could amend the code to output if Number 1 is larger, Number 2 is larger or if they are both equal

⌨️ Coding Activity

(1) Create a folder called Y10 AU – CT3

(2) Inside, create a file called Activity 2 – Branched Conditional.py

(3) Paste the code below into it

(4) Complete the missing code directly beneath each block of arrow comments

#---------------------- Global Variables ----------------------------

#====> Initialise a variable called num1
#====> Assign an empty integer to it


#====> Initialise a variable called num2
#====> Assign an empty integer to it


#---------------------- Main Program --------------------------------

#====> Complete this line of code
#====> It should ask the user to input number 1
#====> It should cast the input to integer data
num1 =

#====> Complete this line of code
#====> It should ask the user to input number 2
#====> It should cast the input to integer data



#====> Complete this sequence so it
#====> Outputs if number 1 is greater, number 2 is greater or if they are equal
if ?? > ??:
    print("Suitable message")

elif ?? > ??:
    print("Suitable message")

else:
    print("Suitable message")

🎯 Extension

(1) Inside, create a file called Activity 2 – Extension.py

(2) Create a grading program, where the user is asked to enter a test score.

(3) Above 45 = 9, Above 40 = 8, Above

⌨️ Coding Activity

(1) Inside today’s folder, create a file called Activity 3 – Exam Grades.py

(2) Create a grading program, where the user is asked to enter a test score:
Above 45 = 9,
Above 40 = 8,
Above 38 = 7,
Above 34 = 6,
Above 30 = 5,
Above 25 = 4,
Above 20 = 3,
Above 15 = 2,
Above 10 = 1,
anything else is a U.

(4) Screenshot your code and put it in OneNote and annotate what is happening.

✍️ Plenary Activity

(1) Open the Mini Whiteboard App and join with the teacher’s code

(2) Answer each question, amend your response and screenshot it into OneNote


Questions
——————————————————————————————
(1) What two terms are used in a conditional sequence?
(2) What must be put at the end of a condition?
(3) What does > mean?
(4) What does < mean?
(5) What three terms are used in a branched conditional sequence?
(6) Why would we wish to use a branched conditional sequence?