WorksheetsWeek 6 - Input/Output Functions
Total questions: 46
Worksheet time: 23mins
The ways computers (and people) GET information
Inputs
Outputs
The ways computers (and people) GIVE information
Inputs
Outputs
What function converts the data in a variable into a 'integer'?
int()
str()
bool()
float()
What function converts the data in a variable into a 'float'?
int()
flt()
bool()
float()
What function converts the data in a variable into a 'string'?
str()
float()
bool()
string()
What does this built-in function do?
input()
Opens the CD tray.
Prompts the user to enter data.
Displays the word 'input'.
Exits the program.
How do you ask for the user to input their name?
name = int("what is your name")
print("What is your name?")
input = name("what is your name?")
name = input("what is your name?")
By default any data inputted by the user is of data type string in python.
True
False
What will be the output of the following command?
x = int(3.6)
print(x)
3
4
Logical error - Can't cast a float value to an integer as data will be lost.
What will be the output of the following command?
x = float(3)
print(x)
Logical error - Can't cast a integer value to an float as data will be added.
3.0
3
What will be the output of the following command?
x = str(3)
print(x)
3
3.0
'3'
What will be the output of the following program, if the user entered 20 and then 41?
Number1 = input("Enter the first number: ")
Number2 = input("Enter the second number: ")
print(Number1 + Number2)
20 41
Syntax error.
61
2041
What can you add to the following code so that python recognises that they are numbers?
Number1 = input("Enter the first number: ")
Number2 = input("Enter the second number: ")
print(Number1 + Number2)
int()
float()
Use a print statement to tell the user to enter a number.
integer()
Fill in the missing section for the code below:
areaOfSquare = (a) (input("Enter area of square: "))
What will be the output of the following program?
gameOnePoints = 200
gameTwoPoints = "456"
print(gameOnePoints + gameTwoPoints)
Logical error - Can't add an integer and string together.
656
"656"
Enter the missing keyword for the program below:
name =_____("Enter name: ")
input
Bob
Input
What is the word (command) used to display numbers and text on the screen?
show
output
command
What can be used to store information and values so that it can be used later?
Graphic
Variable
Output
What is a input?
To plug in something.
A function that allows us to ask the user to enter some data.
Data displayed on a screen.
A function
name=input("What is your name? ")
print("Your name is " + name)
What will be displayed if the user types in "Bob"?
Your name is name
name
Bob
Your name is Bob
What, if anything, is wrong with the following?
input("Type your password: ")
There is no variable
Input commands don't need ( )
Input commands don't need " "
Nothing is wrong
What, if anything, is wrong with the following?
input=x("Type your password: ")
print(x)
The variable should be switched with the input command
Input commands don't need ( )
You can't print x
Nothing is wrong
What, if anything, is wrong with the following?
x=input("Type your password: ")
print("You typed", x)
The variable should be switched with the input command
You can't use commas in print statements
You can't print x
Nothing is wrong
What will be displayed on the Shell when the following statements run?
name = "Peter"
print(name)
name = "Peter"
There is a syntax error message.
Peter
name
Which of the following statements will ask the user for a favorite color and store the answer in the "color" variable?
color = input("What is your favorite color?")
input("What is your favorite color?", color)
input = color("What is your favorite color?")
color = print("What is your favorite color?")
Which parameter is used to print text in columns?
\n
end = ""
sep = ""
\t
What will be displayed on the Shell when the following statements run and name is Adam?
name = input("What is your name?")
print("Hello",name,". My name is Kelly.")
Hello, Adam, . My name is Kelly.
Hello Adam.
My name is Kelly.
Hello Adam . My name is Kelly.
Hello
Adam
My name is Kelly.
What will be displayed on the Shell when the following statement runs?
print(10,11,12)
10, 11, 12
10 11 12
10
11
12
10,
11,
12
What will be displayed on the Shell when the following statement runs?
print("Have \n a great day")
Have
a great day
Have a great day
Have \n a great day
Have \n a GREAT DAY
What will be displayed on the Shell when the following statement runs?
print("Name\tLastN\tAge")
print("Sandy\tSmith\t9")
Name, LastN, Age
Sandy, Smith, 9
NameLastNAge
SandySmith9
Name\LastN\Age
Sandy\Smith\9
Name LastN Age
Sandy Smith 9
Reads the input and returns a Python type like list, tuple, int, etc.
raw_input( )
input( )
The type( ) function is mainly used for....
lowercase a string
Capitalize a string
Debugging Purposes
Separate by a space
The Modulo Operator (%) does...
Convert a string of text into a floating-point value.
Convert a string of text into integer values.
Each 'word' is separated by a space is capitalized.
Divides one number by another number and returns the remainder.
The Float Function...
Convert a string of text into integer values.
Convert a string of text into a floating-point value.
Divides one number by another number and returns the remainder.
All characters of a string are made to switch case. Upper becomes lower and vice versa.
The Integer Function...
All characters of a string are made to switch case. Upper becomes lower and vice versa.
Divides one number by another number and returns the remainder.
Convert a string of text into a floating-point value.
Convert a string of text into integer values.
The comma ( , ) method does...
Convert a string of text into integer values.
Combines printable items with a space.
Convert a string of text into a floating-point value.
Divides one number by another number and returns the remainder.
Integers are...
Decimals
Whole Numbers
Floats
Extra Decimals
Floats are...
Decimals
Whole Numbers
Integers
Extra Decimals
The escape sequence for a double quote is?
\"
/"
\\"
//"
The escape sequence for a single quote is?
\'
/'
\\'
//'
The escape sequence for a backslash character is?
\
/
\\
//
.title( ) makes all your text?
Snake Case
Lower Case
Capitalized
Initial Caps
.lower( ) makes all your text?
Snake Case
Lower Case
Capitalized
Initial Caps
.upper( ) makes all your text?
Snake Case
Lower Case
Capitalized
Initial Caps
.upper(), .lower(), .title() are all types of
Variables
Integers
Floats
Methods
Strings can be added together using what process?
Float
Concatenation
Integers
Variable
