Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

L1 Python KPRIDE: Output, Input and Variables

star
star
star
star
star
Last updated 3 months ago
14 Nsɛmmisa

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
1
1
1
1
1
1

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?

Code

#Run the program, then change 12 to another number.

#What happens if you remove the " " from "12"?

myAge = "12"

myName = input("What is your name? ")

print("Wow! My name is " + myName + " too!")

print("I am " + myAge + " years old!")

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
Asemmisa {{asɛmmisaAhyɛnsode}}
8.

Make a program to output

"Good morning, user!"

1
Asemmisa {{asɛmmisaAhyɛnsode}}
9.

Ask the user for their first name.

Then display "Hello" to the user with their name.

Hello [first name]

1
Asemmisa {{asɛmmisaAhyɛnsode}}
10.

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
1
1
1
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

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

print ("Hello World")

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What will be printed by the following code:

print(5 + 3)?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What will be printed by the following code:

print('Hello' + ' World')

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

What will be printed by the following code:

print(10 - 2)

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What will be printed by the following code:

print(2 * 4)

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What will be printed by the following code:

myName = "Amy"

print(myName)

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What will be printed by the following code:

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

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

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

Hello [first name] [last name]

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

Ask the user for two numbers. Then add them both. Display the total.

Number 1: 5

Number 2: 3

Outputs: 8

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

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

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

ASCII art is a type of art where an image is made from keyboard characters such

0

/|\

/\

Create a program to output ASCII Art.

(https://www.asciiart.eu/)