wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

print(), int and input() - Python

Total questions: 11

Worksheet time: 8mins

Name
Class
Date
1.

What is missing from this line of code?

print(Hello world!)

a)

Speech marks!

print("Hello world!")

b)

Capital P!

Print(Hello world!)

c)

Space before brackets!

print (Hello world)

2.

What is wrong with this line of code?

(print "how tall are you?")

a)

Needs another pair of brackets

(print("how tall are you?"))

b)

Remove outside brackets, surround text with brackets instead:

print("how tall are you?")

3.

What needs correcting in this line of code?

print('Goodbye world!')

a)

Add an extra space after print

print ('Goodbye world!')

b)

Single quotes should be double quotes

print("Goodbye world!")

c)

Remove exclamation mark

print('Goodbye world')

4.

What needs to be fixed in this line of code?

print(3 + 5 =, 3 + 5)

a)

Remove parentheses

print 3 + 5 =, 3 + 5

b)

Add quotes around text

print("3 + 5 =", 3 + 5)

c)

Remove comma

print(3 + 5 = 3 + 5)

5.

What needs to be added to make num1 a whole number?

num1 = input("Enter an integer")

a)

Wrap the input inside an int() function

num1 = int(input("Enter an integer"))

b)

Clearer text inside the input brackets

num1 = input("Enter an integer - which is a whole number, no decimals!")

6.

Turn num1 into a whole number

num1 = (a)   input("Enter an integer"))

7.

What will the following code print if you type in 7?

num1 = input("Enter an integer")

print("Your number becomes: ", num1 + 10)

a)

Your number becomes 17

b)

Your numbers becomes: 710

c)

TypeError: must be str, not int

d)

Your number becomes: 17

8.

What will the following code print if you type in 7?

num1 = int(input("Enter an integer"))

print("Your number becomes: ", num1 + 10)

a)

Your number becomes 17

b)

Your number becomes: 17

c)

Your number becomes 710

9.

What is the best way to ask for, and be able to use two integers from a user?

a)

nums = int(input("Enter two numbers"))

b)

num1=int(input("Enter first number"))

num2=int(input("Enter second number"))

10.

What will the following code print if you type in 5?

num1 = int(input("Enter an integer"))

print("Your number becomes: ", num1 * 2)

a)

Your number becomes 10

b)

Your number becomes: 10

c)

Your number becomes 52

d)

Your number becomes: 52

11.

What is the output of this code if you input '3'?

num1 = input("Enter a number")

print("Your number is: ", num1 + num1)

a)

Your number is: 3

b)

Your number is: 33

c)

Your number is: 6