wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python 02

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

#What is the difference between randint and randrange ?


randint(0,5)

randrange(0,5)

a)

randint randomize from 0,1,2,3,4,5

b)

randrange randomize from 0,1,2,3,4

c)

both are correct

d)

both are incorrect

2.

What button do you press to compile (run) your program so that it runs in the shell?

a)

F5

b)

F3

c)

F8

d)

F9

3.

choice(list) do?

a)

Randomize a set of numbers

b)

Randomize a list

c)

Randomize a letters of a string

d)

All answers are correct

4.

#What is the output?

a)

nothing

b)

hallo

c)

Error

d)

HALLO

5.

#The word "SECRET" is entered but code does not work? What must be placed at (*)?

a)

.lower()

b)

.upper()

c)

.capitalize()

d)

.title()

6.

Everytime you want to use random. What must you first do?

a)

import the random module

b)

random var must be initialized

c)

None of these answers

d)

random list must be initialized

7.

#What is the output?

a)

yes

b)

no

c)

Error

d)

Nothing

8.

#In turtle, what is the short way to write forward, backward, right, left?

a)

fd, bk, rt, lt

b)

f, b, r, l

c)

None of these

d)

fo, ba, ri, le

9.

#How do you define a string?

a)

string = " "

b)

string = 0

c)

string = { }

d)

string = [ ]

10.

#How do you define an integer?

a)

integer = " "

b)

integer = 0

c)

integer = { }

d)

integer = [ ]

11.

#How do you define a list?

a)

myList = " "

b)

myList = o

c)

myList = [ ]

d)

myList = { }

12.

a <= b

a)

a is less than b

b)

a is less than or equal to b

c)

a is more than b

d)

a is more than or equal to b

13.

a >= b

a)

a is greater than b

b)

a is greater or equal to b

c)

a is less than b

d)

a is less than or equal to b

14.

#What will be printed?


name = int(input("Enter your name "))

print(name)

a)

The name you have entered

b)

Error

15.

#What is the output?

a)

prints "Hi" 5 times

b)

calls say() 1 time

c)

Error

d)

print "Hi" 1 time