wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 17

Worksheet time: 34mins

Name
Class
Date
1.

What will this python code do?

print("Hello, World")

a)

Display Hello, World

b)

Sent a message to our printer to print Hello, World in a paper

c)

Display "Hello, World"

d)

Nothing its syntax is wrong

2.

how do we assign to the variable x a value of 5?

a)

var x = 5;

b)

var x = 5

c)

x = 5

d)

(x) == 5

3.

Whats wrong with the script below?

print(a+b)

a = 5

b = 10

a)

The program doesn' t now what a and b is.

b)

The print function should be print("a+b")

c)

The print function should be print(a + b)

4.

click the correct if function:

a)

if x = 5:

b)

if x = num(5):

c)

if x == 5:

d)

if x = float(num(5)):

5.

Whats the correct boolean type:

a)

x == 5

b)

x = 5

c)

x = condition(True)

d)

x = True

e)

x == True

6.

why will the following script won't work?

user_input1 = input("Enter a number: ")

user_input2 = input("Enter a second number: ")


print(user_input1 + user_input2)

a)

Because variables cannot be longer than 1 word

b)

Because user_input1 and user_input2 is a string

c)

Because input is an invalid function

d)

Because python will always thing that it has to add 1+2

e)

It will work

7.

Click all the functions that exist in python:

a)

elif

b)

function

c)

if

d)

float()

e)

key_input

8.

Which of the following is a GUI extension for python (Graphical User Interface)

a)

extension.py.gui

b)

Python.gui

c)

tkinter

d)

root

9.

what is the following:

x = [3, 5, 7, 10, 9]

a)

A boolean

b)

A tuple

c)

A list

d)

A string

10.

How many times will the following code execute:

i = 0

while i <= 10:

print(i)

i += i

a)

Infinity

b)

None because <= isnt valid

c)

10

d)

9

11.

When we get an input what type of variable is it?Examble:

input_var = input("Input: ")

a)

float

b)

string

c)

int

d)

key

12.

In the below function how is the the thing inside the brackets called:

def handle_turn(current_turn):

a)

Parameter

b)

Condition

c)

Info

d)

Def info

e)

String

13.

in:

import random

whats random?

a)

function

b)

module

c)

External_function

d)

External_module

e)

I.E (Importable Element)

14.

Which of the following is correc tif x is a boolean and we want to check if x is equal to True.

a)

if x == "True":

b)

if x == True:

c)

if x:

d)

if x = True:

15.

What will the below line of code print?

print(3**2)

a)

9

b)

12

c)

10

d)

5

16.

Which code will work?

1) num1 = input("Number 1")

num2 = input("Number 2")

print(num1+num2)


2)num1 = float(input("Number1")

num2= float(input("Number 2")

print(num1+num2)

a)

1

b)

2

17.

What will the code below print if num1 = 5 and num2 = 8?

num1 = input("Number 1")

num2 = input("Number 2")

print(num1+num2)

a)

85

b)

58

c)

5+8

d)

None of the above