wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 55

Worksheet time: 42mins

Name
Class
Date
1.

What is the output of this function?
print("www.cisco.com".lstrip("w."))

(a)  

2.

Which of these methods uses whitespace characters to convert a string into a list?

a)

Convert

b)

Seperate

c)

Replace

d)

Join

e)

Split

3.

What is the output of this function?
alpha = "abcde"
print(min(alpha))

(a)  

4.

What is the output of this function?
alpha = "abcde"
print(alpha + "f")

(a)  

5.

What is the output of this function?
i_am = 'I\'m'
print(len(i_am))

(a)  

6.

What is the output of this function?
print("aAbByYzZaA".index("Z"))

(a)  

7.

What is the output of this function?
alpha = "vwxyz"
print(min(alpha))

(a)  

8.

Which of these assertions would result in an error?

a)

assert 'alpha' == 'alpha'

b)


None of these would result in an error

c)

assert 10 == '10'

d)

All of these would result in an error

e)

assert 5 < 10

9.

What is the output of this function?
print("pythoninstitute.org".lstrip(".org"))

(a)  

10.

What is the output of this function?
print("zeta".endswith("et"))

(a)  

11.

What is the output of this function?
print("theta".find('ha'))

(a)  

12.

Which of these methods will attempt to center a string inside a field of a specified width?

a)


orient

b)


middle

c)


center

d)


justify

e)


align

13.

What is the output of this function?
alpha = "abdefg"
print(alpha[-5:5])

(a)  

14.

Which of these is NOT an ASCII character?

a)

A

b)

z

c)

/

d)

!

e)

These are all ASCII characters

15.

What is the result of the function print("SiGmA-60".lower()) ?

a)


sigma60

b)

sigma

c)

sigma-60

d)


sigma-

e)

siGmA-60

16.

What is the output of this function?
print("theta".find('eta'))

(a)  

17.

What is the output of this function?
print("theta theta".rfind('the'))

(a)  

18.

What is the output of this function?
alphabet = "abcdefghijklmnopqrstuvwxyz"
print("f" not in alphabet)

(a)  

19.

What is the output of this function?
empty = "" print(len(empty))

(a)  

20.

What feature builds in additional alphabets to the ASCII database?

a)


Universality

b)

pip

c)

Internationalization

d)

Plugins

e)


Dictionaries

21.

Which of these functions will convert a code point value into a character?

a)


chr

b)

code

c)


ordinal

d)


ord

e)


character

22.

What is the result of the function print('aBcD'.capitalize()) ?

a)


AbCd

b)


abcD

c)

Abcd

d)

abcd

e)

ABCD

23.

What is the output of this function?
print(",".join(["omicron", "pi", "rho"]))

(a)  

24.

What is the output of this function?
alphabet = "abcdefghijklmnopqrstuvwxyz"
print("F" in alphabet)

(a)  

25.

What is the output of this function?
print("www.wisco.com".lstrip("w."))

(a)  

26.

What is the output of this function?
print('alpha' == 'alpha')

(a)  

27.

What is the output of this function?
print("www.wisco.com".rstrip(".com"))

(a)  

28.

Which of these keywords can be used to manually call an exception?

a)

stop

b)

raise

c)

call

d)

exception

e)

error

29.

Which of these functions will convert an entity into a list?

a)


iterate

b)


list

c)

convert

d)

items

e)

separate

30.

What is the output of this function?
greek = ['omega', 'alpha', 'pi', 'gamma']
print(sorted(greek)[-1])

(a)  

31.

Which of these terms refers to the brief result of the platform function?

a)


brief

b)

terse

c)


short

d)

alias

e)

concise

32.

What command displays the current pip version?

a)

pip

b)


pip software

c)


pip show

d)

pip --version

e)

pip help

33.

Why are random numbers in computing referred to as pseudorandom?

a)


Random is reserved for nature, where pseudorandom is reserved for science

b)


The numbers produced can only be valued between 1 and 100

c)

Their values are determined using a pre-defined algorithm

d)

The algorithm that produces the numbers only accepts positive values

e)


The random values are hand-coded by an administrator

34.

How would you load just the sin function from the math module using sine as an alias?

(a)  

35.

The Python Package Index is located at what site?

36.

A random number generator uses what value in combination with an algorithm to produce a pseudorandom number?

a)


the current CPU frequency

b)


the current time

c)


the current username

d)


a seed value

e)

the current PSU wattage

37.

What function is used to modify a random number generator's algorithm's base value?

a)


time

b)

psu

c)

seed

d)

user

e)


cpu

38.

What keyword in a program allows a module to become usable?

a)


try

b)

start

c)


load

d)

import

e)


init

39.

How would you load just the pi variable from the math module using x as an alias?

(a)  

40.

What variable can be used to determine whether a program is being run directly or as a module?

a)

__module__

b)

__script__

c)


__python__

d)


__program__

e)

__name_ _

41.

Which of these variables contains a list of directories that Python searches for modules in?

a)


ls

b)


folders

c)


list

d)


dir

e)


path

42.

How would you load just the pi variable from the math module?

(a)  

43.

Which of these functions will display a list of a module's contents?

a)

dir

b)


help

c)


show

d)


list

e)


ls

44.

What command displays more information about the installed package pygame?

a)


pip list pygame

b)


pip all pygame

c)


pip show pygame

d)

pip display pygame

e)


pip help pygame

45.

Write a print function to show the variable tau from the math module.

(a)  

46.

What is returned by the python_implementation function when used on a standard Python install?

a)


Python

b)

CPython

c)

py

d)


Pypi

e)

JPython

47.

What is the highest possible number produced by this function?
print(randrange(0 , 100))

(a)  

48.

A piece of software required by another piece of software is referred to as a what?

a)

base requirement

b)

runtime

c)

OS

d)


dependency

e)


library

49.

What command displays all packages installed with pip?

a)


pip help

b)


pip all

c)


pip list

d)

pip show

e)


pip packages

50.

What character is used to browse down into subfolders within a package?

a)

.

b)

~-

c)


_

d)


/

51.

Write a print function to show the variable pi from the math module.

(a)  

52.

What subfolder is created when loading a module?

a)

__ init __

b)

__package__

c)

__python__

d)

__pycache__

e)

__module__

53.

What file is required to be at the base directory of a python package?

a)

__base__.py

b)

__program__.py

c)

__package__.py

d)

__script__.py

e)

__init.py__

54.

What is the highest possible number produced by this function?
print(randrange(1 , 10))

(a)  

55.

How would you load the random module?

(a)