Search Header Logo
Summer Lesson 04

Summer Lesson 04

Assessment

Presentation

•

Computers

•

9th - 12th Grade

•

Practice Problem

•

Hard

Created by

Robert Giordano

Used 1+ times

FREE Resource

5 Slides • 3 Questions

1

media

Lesson 04

User Input

2

media

Usability

One of the things that makes programs good is their
usability. If the user cannot interact with a program,
they are unlikely to use it. So it’s important for us as
programmers to make sure that our programs can
include the user in it’s operation.

We do this by taking user input

3

media

User Input

Python has an easy to use input command. The main
thing to understand is that you need to make sure that
there is a variable to store the value that the user
inputs.

The format is:

variable = input(PROMPT)

In the console whatever you typed as the PROMPT will
be printed and the console will wait for the user to
input a value. Once they input a value, the variable will
hold the value they enter.

4

Drag and Drop

Complete the syntax to take user input in Python:

​
= ​
(​
)
Drag these tiles and drop them in the correct blank above
variable
input
PROMPT
scanner
cin
readIn

5

media
media
media

Example:

In this example the variable userNum will receive the
value that the user enters.

Now we can see that the number the user enters is
printed.

6

Fill in the Blanks

Fill in the blank to complete the code:

name =

("Enter your name: ")

7

media
media
media

Data Type of Input

We can check the data type of the input data to see
how it is being stored.

Here we can see that when we input a value, it is
stored as a String (str). If we want to use that value
later in a calculation it will have to be type cast to a
numeric data type.

8

Fill in the Blanks

Fill in the blank to take in an integer from the user:

num = ___(_____("Enter an integer: "))

pattern-tertiary
media

Lesson 04

User Input

Show answer

Auto Play

Slide 1 / 8

SLIDE