L1 Python KPRIDE: Output, Input and Variables

Last updated 7 months ago
13 questions

For GCSE, you must know the following for programming:

  • Outputs and Inputs
  • Variables
  • Maths Operators
  • Random numbers
  • Strings and Casting
  • Booleans
  • If, elif, else
  • Nested Ifs
  • For loops
  • While loops
  • Nested loops
  • Arrays/Lists
  • 2D Lists
  • File handling
  • Subprograms(functions/procedures)

Warm-up Practice:
https://type.withcode.uk/python/Variables_and_Constants

Learning Objectives:

  • I can tell someone what an algorithm is
  • I know how to create a simple Python Program (Input and Output)
  • I can explain and debug an algorithm/Python Program

Keywords

  1. Input - Taking data from the user to the computer
  2. Output - Sending data back to the user (such as sound, text, or changes to the screen)
  3. Variable - A name that has a value that can change when the program is running (such as a score)
  4. Algorithm - An order set of step-by-step instructions to solve a problem
  5. Debug - Finding and fixing problems in your code

Predict and Run

Look at the code for each question.
What do you think will be the output?
What is the actual output?
1

What do you think will be the output to this code:

print ("Hello World")

1

What will be printed by the following code:

print(5 + 3)?

1

What will be printed by the following code:

print('Hello' + ' World')

1

What will be printed by the following code:

print(10 - 2)

1

What will be printed by the following code:

print(2 * 4)

1

What will be printed by the following code:

myName = "Amy"
print(myName)

1

What will be printed by the following code:

myAge = input("How old are you?")

Investigate

  1. Look at the code on the right.
  2. Run it and see what it does.
  3. Click on the pencil icon at the top to see the code again.
  4. Change "12" to another number.
  5. What happens if you get rid of the Speech marks""? Does it still work?

Debug

Click on each link and try dragging and dropping code into the correct order
https://7strikelink7.github.io/NormalPythonParsons/parsons/Outputs.html
https://7strikelink7.github.io/NormalPythonParsons/parsons/Variables.html
https://7strikelink7.github.io/NormalPythonParsons/parsons/Inputs.html

Extend

Help:
print ( ) is used to output text
input( ) is used to get the user to type something

Variables store values that can change.
Name = Value here
e.g. myName = "John"
1

Make a program to output
"Good morning, user!"

1

Ask the user for their first name.
Then display "Hello" to the user with their name.
Hello [first name]

1

Make a program to create a variable called myAge. Display "I am also age years old!"
Enter your age: 12
I am also 12 years old!

1

Ask the user for their first name and their surname/last name. Display "Hello" with their full name
Hello [first name] [last name]

1

Ask the user for two numbers. Then add them both. Display the total.
Number 1: 5
Number 2: 3
Outputs: 8

1

CHALLENGE:

Ask the user for three numbers. Add the first two together and divide by the third number. Output the result
Number 1: 5
Number 2: 3
Number 3: 2
Number 1 + number 2 = 8
8 / Number 3 = 2