
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
Python Programming
Input Function
By Mr. Dwedari
5
Input Function
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
Input Function
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
Casting
(Data-type conversion)
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 Functions
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
Type answer...
28
Fill in the Blanks
Type answer...
29
Fill in the Blanks
Type answer...
30
Fill in the Blanks
Type answer...
31
Fill in the Blanks
Type answer...
32
Fill in the Blanks
Type answer...
33
Fill in the Blanks
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
35 questions
Inheritance and Punnett Squares
Presentation
•
7th Grade
36 questions
Surface Area and Volume Study Guide
Presentation
•
7th Grade
32 questions
Synthetic Materials: Lesson 3 - Materials Science
Presentation
•
7th Grade
32 questions
Volume Lesson
Presentation
•
7th Grade
31 questions
CS Lesson 4
Presentation
•
6th - 8th Grade
35 questions
Parts of a Computer
Presentation
•
7th Grade
35 questions
Anglo Colonization of Texas
Presentation
•
7th Grade
35 questions
Unit 2 Oceans Review 7th Grade Science
Presentation
•
7th Grade
Popular Resources on Wayground
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
30 questions
GVMS House Trivia 2026
Quiz
•
6th - 8th Grade