L1 Python KPRIDE: Output, Input and Variables
star
star
star
star
star
Last updated 7 months ago
13 questions
Keywords
- Input - Taking data from the user to the computer
- Output - Sending data back to the user (such as sound, text, or changes to the screen)
- Variable - A name that has a value that can change when the program is running (such as a score)
- Algorithm - An order set of step-by-step instructions to solve a problem
- 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")
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)?
What will be printed by the following code:
print(5 + 3)?
1
What will be printed by the following code:
print('Hello' + ' World')
What will be printed by the following code:
print('Hello' + ' World')
1
What will be printed by the following code:
print(10 - 2)
What will be printed by the following code:
print(10 - 2)
1
What will be printed by the following code:
print(2 * 4)
What will be printed by the following code:
print(2 * 4)
1
What will be printed by the following code:
myName = "Amy"print(myName)
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?")
What will be printed by the following code:
myAge = input("How old are you?")
Investigate
- Look at the code on the right.
- Run it and see what it does.
- Click on the pencil icon at the top to see the code again.
- Change "12" to another number.
- What happens if you get rid of the Speech marks""? Does it still work?
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!"
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]
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: 12I am also 12 years old!
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 nameHello [first name] [last name]
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: 5Number 2: 3Outputs: 8
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 resultNumber 1: 5Number 2: 3Number 3: 2Number 1 + number 2 = 88 / Number 3 = 2
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