wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Week 6 - Input/Output Functions

Total questions: 46

Worksheet time: 23mins

Name
Class
Date
1.

The ways computers (and people) GET information

a)

Inputs

b)

Outputs

2.

The ways computers (and people) GIVE information

a)

Inputs

b)

Outputs

3.

What function converts the data in a variable into a 'integer'?

a)

int()

b)

str()

c)

bool()

d)

float()

4.

What function converts the data in a variable into a 'float'?

a)

int()

b)

flt()

c)

bool()

d)

float()

5.

What function converts the data in a variable into a 'string'?

a)

str()

b)

float()

c)

bool()

d)

string()

6.

What does this built-in function do?

input()

a)

Opens the CD tray.

b)

Prompts the user to enter data.

c)

Displays the word 'input'.

d)

Exits the program.

7.

How do you ask for the user to input their name?

a)

name = int("what is your name")

b)

print("What is your name?")

c)

input = name("what is your name?")

d)

name = input("what is your name?")

8.

By default any data inputted by the user is of data type string in python.

a)

True

b)

False

9.

What will be the output of the following command?

x = int(3.6)

print(x)

a)

3

b)

4

c)

Logical error - Can't cast a float value to an integer as data will be lost.

10.

What will be the output of the following command?

x = float(3)

print(x)

a)

Logical error - Can't cast a integer value to an float as data will be added.

b)

3.0

c)

3

11.

What will be the output of the following command?

x = str(3)

print(x)

a)

3

b)

3.0

c)

'3'

12.

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)

a)

20 41

b)

Syntax error.

c)

61

d)

2041

13.

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)

a)

int()

b)

float()

c)

Use a print statement to tell the user to enter a number.

d)

integer()

14.

Fill in the missing section for the code below:

areaOfSquare = (a)   (input("Enter area of square: "))

15.

What will be the output of the following program?

gameOnePoints = 200

gameTwoPoints = "456"

print(gameOnePoints + gameTwoPoints)

a)

Logical error - Can't add an integer and string together.

b)

656

c)

"656"

16.

Enter the missing keyword for the program below:

name =_____("Enter name: ")

a)

input

b)

print

c)

Bob

d)

Input

17.

What is the word (command) used to display numbers and text on the screen?

a)

print

b)

show

c)

output

d)

command

18.

What can be used to store information and values so that it can be used later?

a)

Graphic

b)

Variable

c)

Print

d)

Output

19.

What is a input?

a)

To plug in something.

b)

A function that allows us to ask the user to enter some data.

c)

Data displayed on a screen.

d)

A function

20.

name=input("What is your name? ")

print("Your name is " + name)

What will be displayed if the user types in "Bob"?

a)

Your name is name

b)

name

c)

Bob

d)

Your name is Bob

21.

What, if anything, is wrong with the following?

input("Type your password: ")

a)

There is no variable

b)

Input commands don't need ( )

c)

Input commands don't need " "

d)

Nothing is wrong

22.

What, if anything, is wrong with the following?

input=x("Type your password: ")

print(x)

a)

The variable should be switched with the input command

b)

Input commands don't need ( )

c)

You can't print x

d)

Nothing is wrong

23.

What, if anything, is wrong with the following?

x=input("Type your password: ")

print("You typed", x)

a)

The variable should be switched with the input command

b)

You can't use commas in print statements

c)

You can't print x

d)

Nothing is wrong

24.

What will be displayed on the Shell when the following statements run?

name = "Peter"

print(name)

a)

name = "Peter"

b)

There is a syntax error message.

c)

Peter

d)

name

25.

Which of the following statements will ask the user for a favorite color and store the answer in the "color" variable?

a)

color = input("What is your favorite color?")

b)

input("What is your favorite color?", color)

c)

input = color("What is your favorite color?")

d)

color = print("What is your favorite color?")

26.

Which parameter is used to print text in columns?

a)

\n

b)

end = ""

c)

sep = ""

d)

\t

27.

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.")

a)

Hello, Adam, . My name is Kelly.

b)

Hello Adam.

My name is Kelly.

c)

Hello Adam . My name is Kelly.

d)

Hello

Adam

My name is Kelly.

28.

What will be displayed on the Shell when the following statement runs?

print(10,11,12)

a)

10, 11, 12

b)

10 11 12

c)

10

11

12

d)

10,

11,

12

29.

What will be displayed on the Shell when the following statement runs?

print("Have \n a great day")

a)

Have

a great day

b)

Have a great day

c)

Have \n a great day

d)

Have \n a GREAT DAY

30.

What will be displayed on the Shell when the following statement runs?

print("Name\tLastN\tAge")

print("Sandy\tSmith\t9")

a)

Name, LastN, Age

Sandy, Smith, 9

b)

NameLastNAge

SandySmith9

c)

Name\LastN\Age

Sandy\Smith\9

d)

Name LastN Age

Sandy Smith 9

31.

Reads the input and returns a Python type like list, tuple, int, etc.

a)

raw_input( )

b)

input( )

32.

The type( ) function is mainly used for....

a)

lowercase a string

b)

Capitalize a string

c)

Debugging Purposes

d)

Separate by a space

33.

The Modulo Operator (%) does...

a)

Convert a string of text into a floating-point value.

b)

Convert a string of text into integer values.

c)

Each 'word' is separated by a space is capitalized.

d)

Divides one number by another number and returns the remainder.

34.

The Float Function...

a)

Convert a string of text into integer values.

b)

Convert a string of text into a floating-point value.

c)

Divides one number by another number and returns the remainder.

d)

All characters of a string are made to switch case.  Upper becomes lower and vice versa.

35.

The Integer Function...

a)

All characters of a string are made to switch case.  Upper becomes lower and vice versa.

b)

Divides one number by another number and returns the remainder.

c)

Convert a string of text into a floating-point value.

d)

Convert a string of text into integer values.

36.

The comma ( , ) method does...

a)

Convert a string of text into integer values.

b)

Combines printable items with a space.

c)

Convert a string of text into a floating-point value.

d)

Divides one number by another number and returns the remainder.

37.

Integers are...

a)

Decimals

b)

Whole Numbers

c)

Floats

d)

Extra Decimals

38.

Floats are...

a)

Decimals

b)

Whole Numbers

c)

Integers

d)

Extra Decimals

39.

The escape sequence for a double quote is?

a)

\"

b)

/"

c)

\\"

d)

//"

40.

The escape sequence for a single quote is?

a)

\'

b)

/'

c)

\\'

d)

//'

41.

The escape sequence for a backslash character is?

a)

\

b)

/

c)

\\

d)

//

42.

.title( ) makes all your text?

a)

Snake Case

b)

Lower Case

c)

Capitalized

d)

Initial Caps

43.

.lower( ) makes all your text?

a)

Snake Case

b)

Lower Case

c)

Capitalized

d)

Initial Caps

44.

.upper( ) makes all your text?

a)

Snake Case

b)

Lower Case

c)

Capitalized

d)

Initial Caps

45.

.upper(), .lower(), .title() are all types of

a)

Variables

b)

Integers

c)

Floats

d)

Methods

46.

Strings can be added together using what process?

a)

Float

b)

Concatenation

c)

Integers

d)

Variable