
Input Function
Presentation
•
Computers
•
7th Grade
•
Practice Problem
•
Easy
M Dwedari
Used 11+ times
FREE Resource
16 Slides • 23 Questions
1
Open Ended
What is syntax in programming language (3 minutes)?
2
Remember
Syntax is the rules of a programming language.
the arrangement of words and phrases to create well-formed sentences in a language. "the syntax of English"
In programming:
3
Multiple Choice
What is syntax in programming language?
Syntax is the word used to describe an error
Syntax is the rules of the programming language
It is used to read information
It is used to output information
4
Input Function
By Mr. Dwedari
5
The Input function reads a line from the console (keyboard).
The Input function converts all information that it receives into a string
Syntax :
variable = input("Type here a message for the user ")
6
Example :
studentName=input("What is your name? ")
Remember, The Input function converts all information that it receives into a string
Syntax of Input Funtion:
variable = input("Type here a message for the user ")
7
Poll
Discuss in pairs then predict (1 minutes)
What does this code do?
Syntax error
Line 1: Asks a user for their name
Line 2: Displays the user entry in the shell
Line 1: Asks a user for their name
Line 2: Displays "name" in the shell
8
Test it in Thonny to find the correct answer (3-minutes)
9
Multiple Choice
Now, as you have tested it in Thonny
When the user had entered Kate what did this code display on the screen?
Kate
name
error
10
Open Ended
Use the code in the picture as a starting point to think how you can modify/change it to:
1- Ask the user for their first name and allow them to enter it
2- Ask the user for their last name and allow them to enter it
3- Display in the shell, the first name followed by the last name
(5 minutes)
Test your code in Thonny then copy your answer here.
Do not answer before you test it in Thonny
11
Multiple Choice
I have written three programs to answer the previous question
Remember, the program should:
1- Ask the user for their first name and allow them to enter it
2- Ask the user for their last name and allow them to enter it
3- Display in the shell, the first name followed by the last name.
Click the correct one
12
Open Ended
In Thonny, Modify the code shown to (2 minutes):
Display the message "Welcome" followed by the user's first name and last name
Copy your code from Thonny then paste it here
13
Solution
14
Poll
Predict ...
if the user enters for item1, 7
and for item2, 10
What will line 3 display?
The total amount is item1+item2
The total amount is 17
The total amount is 710
The total amount is 107
15
Test it in Thonny to find the correct answer (3-minutes)
16
Multiple Choice
Now, as you have tested it in Thonny
What has the code displayed in the shell when the user had entered 7 for item1
and for 10 item2?
The total amount is item1+item2
The total amount is 17
The total amount is 710
The total amount is 107
17
In programming, casting is used to convert data-type to a different one based on what it will be used for.
Remember ...
In programming, we can assign different types of data to variables and the choice of data type depends on the use of this variable.
18
Example
item = "crisp"
quantity = 5.2
print (quantity, item,"bags")
19
Example
item = "crisp"
quantity = 5.2
print (quantity, item,"bags")
The data type of the variable quantity is float because it is a decimal number
20
Multiple Choice
What will line 3 display?
quantity item bags
bags
5 crisp bags
5.2 crisp bags
21
Example
item = "crisp"
quantity = 5.2
print (quantity, item,"bags")
The data type of the variable quantity is float because it is a decimal number
quantity = int(quantity)
Converts the variable "quantity" from float to integer by deleting the numbers after the decimal point
Quantity of crisp bags can't have a decimal point so it is better to convert it to an integer:
22
Example
item = "crisp"
quantity = 5.2
quantity = int(quantity)
print (quantity, item,"bags")
Converts the variable quantity from float to integer by deleting the numbers after the decimal point
23
Poll
Predict ...
What will line 4 display?
5.0 crisp bags
5.2 crisp bags
5 crisp bags
quantity item bags
24
Test it in Thonny to find the correct answer (3-minutes)
25
Multiple Choice
Now, as you have tested it in Thonny
What did this code display on the screen?
5.0 crisp bags
5.2 crisp bags
5 crisp bags
quantity item bags
26
Casting Function | What it does? |
|---|---|
int ( ) | converts any value/variable between the bracket to Integer (whole number) |
float ( ) | converts any value/variable between the bracket to Float (a number with decimal point) |
str ( ) | converts any value/variable between the brackets to String |
bool ( ) | converts any value/variable between the brackets to Boolean |
27
Fill in the Blanks
What is the data type of the variable "answer" on line 1?
Type answer...
28
Fill in the Blanks
What is the data type of the variable "answer" on line 2?
Type answer...
29
Fill in the Blanks
What is the data type of the variable "amount" on line 1?
Type answer...
30
Fill in the Blanks
What is the data type of the variable "amount" on line 2?
Type answer...
31
Fill in the Blanks
What is the data type of the variable "amount" on line 2?
Type answer...
32
Fill in the Blanks
What is the data type of the variable "price" on line 1?
Type answer...
33
Fill in the Blanks
What is the data type of the variable "price" on line 2?
Type answer...
34
Poll
Discuss in pairs then predict ...
What will line 3 display?
6
6.0
price
"6"
price
35
Test it in Thonny to find the correct answer (3-minutes)
36
Multiple Choice
Now, as you have tested it in Thonny
What did this code display on the screen?
price
6
"6"
6.0
37
Poll
Discuss in pairs then predict ...
What will line 2 display?
Amount £1
Amount £1.25
Amount £price
Amount £1.00
38
Test it in Thonny to find the correct answer (3-minutes)
39
Multiple Choice
Now, as you have tested it in Thonny
What did this code display on the screen?
Amount £1
Amount £1.25
Amount £1.00
Amount £price
What is syntax in programming language (3 minutes)?
Show answer
Auto Play
Slide 1 / 39
OPEN ENDED
Similar Resources on Wayground
34 questions
Introduction to Microsoft Excel
Presentation
•
7th Grade
32 questions
Information Technology
Presentation
•
7th Grade
29 questions
PowerPoint Review
Presentation
•
7th Grade
34 questions
Science 7 Year End Review - Unit D
Presentation
•
7th Grade
33 questions
Lesson 2: Photosynthesis and Cellular Respiration
Presentation
•
7th Grade
35 questions
Math Discovery - B - Geometry
Presentation
•
7th Grade
33 questions
Scientific Notation
Presentation
•
7th Grade
36 questions
Civil Rights Movement
Presentation
•
7th Grade
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade