wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Functional Programming

Total questions: 130

Worksheet time: 1hrs 18mins

Name
Class
Date
1.

What is Python?

a)

It is a high-level and only object-oriented programming language.

b)

It is a low-level and general-purpose programming language.

c)

It is a high-level and general-purpose programming language

d)

It is a high-level and general-purpose app.

2.

Python was created in __ by __.

a)

2000 / Python Software Foundation

b)

2000/ Guido Van Rossum

c)

1991 / Guide Van Rossum

d)

1991 / Guido Van Rossum

3.

Python is NOT __.

a)

faster than Java

b)

powerful

c)

flexible

d)

easy-to-use

4.

Python is dynamic.

a)

True

b)

False

5.

Which type of Programming does Python support?

a)

object-oriented programming

b)

structured programming

c)

functional programming

d)

all of the mentioned

6.

Which of the following is the correct extension of the Python file?

a)

.python

b)

.pi

c)

.py

d)

.p

7.

Which of the following best describes the Python and keyword

a)

It's a logical operator

b)

It's used to create an alias

c)

It's used for debugging

d)

It's used to break out of a loop

8.

Which of the following best describes the Python break keyword

a)

It's a logical operator

b)

It's used to create an alias

c)

It's used for debugging

d)

It's used to break out of a loop

9.

Which of the following best describes the Python def keyword

a)

It's used to defined a class

b)

It's used in conditional statements

c)

It's used to define a function

d)

It's used to delete an object

10.

Which of the following best describes the Python None keyword

a)

it's a null statement, a statement that will do nothing

b)

It's used to create an anonymous function

c)

It's used to define a function

d)

It's used to represents a null value

11.

Which of the following is a python keyword?

a)

True

b)

not

c)

if

d)

All

12.

Which module prints all python keywords?

a)

keyword

b)

keywords

c)

words

d)

keyswords

13.

Identify the invalid variable name

a)

s_a_l_a_r_y

b)

salary____

c)

sal&ary

d)

s1a2l3a4r5y6

14.

Which function is used to find the type of a value?

a)

id()

b)

print()

c)

type()

d)

input()

15.

Which operator is used for exponent?

a)

**

b)

*

c)

$

d)

^

16.

What does the following comparison operator “==” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

17.

What does the following comparison operator “!=” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

18.

What is the result of the following condition if x = 3?

not(x < 5 and x < 10)

a)

True

b)

False

19.

What is the result of the following condition if:

A = 30

B = 21

C = 71

(A > B and A > C) or B < C

a)

True

b)

False

20.

What is the result of the following condition if:

A = 30

B = 21

C = 71

not(B < A and B < C)

a)

True

b)

False

21.

What is the result of the following condition if:

A = 30

B = 21

C = 71

B != A or C < A

a)

True

b)

False

22.

Which of the following declarations is incorrect in python language?

a)

xyzp = 5,000,000

b)

x y z p = 5000 6000 7000 8000

c)

x,y,z,p = 5000, 6000, 7000, 8000

d)

x_y_z_p = 5,000,000

23.

Which of the following words cannot be a variable in python language?

a)

_val

b)

val

c)

try

d)

_try

24.

What are the values of the following Python expressions?

2**(3**2)

(2**3)**2

2**3**2

a)

512, 64, 512

b)

512, 512, 512

c)

64, 512, 64

d)

64, 64, 64

25.

What will be the output of the following Python function?

len(["hello",2, 4, 6])

a)

Error

b)

6

c)

4

d)

3

26.

What will be the output of the following Python code?

print("abc. DEF".capitalize())

a)

Abc. def

b)

abc. def

c)

Abc. Def

d)

ABC. DEF

27.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
28.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

29.

If you want to test more than one condition (chained condition), what do you use after if statement?

a)

elif

b)

else

c)

ifif

d)

else if

30.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

31.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
32.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Failure
d)
Success
 Failure
33.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
34.
What will be printed to the screen?
a)
Failure
b)
Part of the way there!
c)
Success
d)
Nothing
35.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Part of the way there!
d)
Failure
36.

What will be the output of the code displayed?

(a)  

37.

What is the output from the following code?

(a)  

38.

What is the output from the following code?

(a)  

39.

What is the output from the following code?

(a)  

40.

What is the output of the following code?

(a)  

41.

What is the output from the following code?

(a)  

42.

What is the output from the following code?

(a)  

43.

What is the missing line of code?

a)

new = chr(new)

b)

new = ord(new)

c)

new = chr(letter)

d)

print new

44.

What is the missing line of code?

a)

if new > ord('z'):

b)

If new =< ord('z'):

c)

if new > chr('z'):

d)

else next:

45.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

46.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
47.

The above program prints

a)

Numbers 1 to 10 in reverse order

b)

Numbers 1 to 11 in reverse order

c)

Numbers 1 to 10

d)

Numbers 1 to 11

48.

The program above prints

a)

Numbers between 1 and 100 that are multiples of 5

b)

Numbers between 1 and 100

c)

Numbers between 1 and 100 divisible by 5

d)

Numbers between 1 and 101 that are multiples of 5

49.

The code above prints all numbers between 1 and 30 that are

a)

not divisible by 5

b)

divisible by 5

50.

The program above prints the sum of

a)

all odd numbers less than 100

b)

all even numbers less than 100

c)

all numbers less than 100

51.

The program above prints the sum of all the numbers between 0 and 101 that are

a)

alternate odd numbers

b)

alternate even numbers

c)

alternate numbers

52.

The program above prints each number between 1 and 10

a)

as many times as the number itself

b)

10 times

c)

11 times

53.

The program above prints each number between 1 and 10

a)

as many times as the number itself

b)

10 times

c)

11 times

54.

How many times will 1 be printed

a)

3

b)

4

c)

5

d)

6

55.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

56.

What is the output of the program above

a)

10

b)

15

c)

18

d)

17

e)

16

57.

A while loop equivalent of the for loop above is

a)
b)
c)
d)
58.

What is the value of the variable sum after the code above executes

a)

54

b)

44

c)

64

d)

34

e)

74

59.

What does this program print

a)

2 + 2 = 4

4 + 4 = 8

8 + 8 = 16

16 + 16 = 32

32 + 32 = 64

b)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

c)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

2 + 10 = 12

d)

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

2 + 2 = 4

e)

2 + 2 = 4

2 + 4 = 6

2 + 6 = 8

2 + 8 = 10

60.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
61.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
62.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

63.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
64.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)

It displays an output

d)
It loops the code.
65.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
66.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
67.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
68.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
69.

In programming, what is iteration?

a)

The repetition of steps within a program

b)

The order in which instructions are carried out

c)

A decision point in a program

d)

Testing a program to make sure it works

70.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
71.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

72.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

73.

Which kind of loop would be used?


I need a guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

74.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

75.

A: Strings can be changed during execution

B. Strings can be enclosed within single, double or even triple quotes

C. Strings are immutable

a)

A,B & C are True

b)

A,B are True but C is False

c)

B, C are True but A is False

d)

A,C are True but B is False

76.

Find the output of the following code:

>>>str1='Save Soil'

>>>str1.isalnum( )

a)

Save Soil

b)

True

c)

False

77.

Identify the string membership operators of Python

a)

in, not in

b)

like, not like

c)

as, not as

d)

between, not between

78.

The title( ) function

a)

assigns title

b)

returns the title of the file

c)

returns string in title case

79.

Predict the output:

>>>str1="Rajathi Raja"

>>>print(str1.count('Raja'))

a)

1

b)

2

c)

Error

d)

Raja

80.

Predict the output:

>>>saint="Thiruvalluvar"

>>>print(saint[5:])

a)

valluvar

b)

Thiruvalluvar

c)

uvalluvar

d)

Thiru

81.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
82.

Which of the operator can be used in Strings?

a)

+

b)

*

c)

Both of the above

d)

None of the above

83.

word = "amazing"

For the given string if we run word[2:5] what does it mean?

a)

It will extract alphabets from index 2 to index 4

b)

It will extract alphabets from index 2 to index 5

c)

It will extract alphabets from position 2 to position 4

d)

It will extract alphabets from position 2 to position 5

84.

word = "amazing"

For the given string if we run word[2:5:2] what does 2 mean in this function?

a)

It will pick only second alphabet

b)

It will pick only two alphabets

c)

It will pick every alternate alphabet

d)

It will pick first two alphabets

85.

Which method is used to convert a given string in Capital letters?

a)

Capital

b)

Upper

c)

ConverttoUpper

d)

Capitalize

86.

s1="Hello"

n1=10

print(s1+n1)

What is the error in this code?

a)

Print statement not written in quotes

b)

Numeric value not written in quotes

c)

colon not written after the print statement

d)

string cannot be added to a number

87.

s1="Hello"

s2="10"

print(s1+n1)

What is the error in this code?

a)

String 2 written in quotes

b)

String cannot be multiplied with a string

c)

colon not written after print statement

d)

Number written in quotes

88.

Lists are?

a)

Mutable

b)

immutable

89.

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

90.

slicing string X="BOnVoyage"

print X[0:5]

a)

BOnVoy

b)

BOnVo

c)

oyage

d)

bonvo

91.

Slicing string

x="BOnvoyage

print(x[4: ])

a)

BOnvo

b)

bonvo

c)

voyage

d)

VOYAGE

92.

a="god help those who help themselves"

"help" in "a"

a)

true

b)

false

c)

wrong out put

d)

error

93.

Which keyword is used for function?*

a)

define

b)

fun

c)

def

d)

function

94.

Which of the following items are present in the function header?

a)

function name

b)

parameter list

c)

return value

d)

Both A and B

95.

If the return statement is not used inside the function, the function will return:

a)

0

b)

None

c)

Null

d)

Arbitary value

96.

In which part of memory does the system store the parameter and local variables of a function call?

a)

heap

b)

stack

c)

Uninitialized data segment

d)

None of the above

97.

What will be the output of the following Python expression? round(4.576)

a)

4.5

b)

5

c)

4

d)

4.6

98.

Which statement is correct to import all modules from the package

a)

from package import all

b)

from package import *

c)

from package include all

d)

from package include *

99.

What is returned by math.ceil(3.4)?

a)

3

b)

4

c)

4.0

d)

3.0

100.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
101.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
102.
What will print?
a)
nothing
b)
7
c)
z
d)
12
103.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
104.
What will print?
a)
1 2
b)
1
c)
3
d)
5
105.

What term is used to describe data passed into a function?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

106.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

107.

Write the line of code that will call the function.

(a)  

108.

Write the line of code that will define the function, draw_coin

(a)  

109.

Do you call or define a function first?

a)

call

b)

define

110.

Correctly rewrite this line of code!

(a)  

111.

Correctly rewrite this line of code !

(a)  

112.

Rewrite the line of incorrect code using Camel Case to make it correct!

Hint: The mistake is when the function gets called

(a)  

113.

The process of creating a function is as follows

1. Use the keyword def to declare the function

2. Follow with defining the function name

3. Add parameters to the function: they should be within the parentheses() of the function.

4. End this line with a colon after the parenthesis.

5. Indent and then add the statements that the functions should execute

6. Include a return statement if the function should output something. Without the return statement, your function will return an object  - None

What is missing from this function?

a)

return value statement

b)

Variable

c)

Function definition

d)

Parameters

114.

What will be the output of this program?

a)

0

b)

1

c)

2

d)

3

e)

4

115.

The parameters could be a

a)

Variable

b)

Literal

c)

Expression

d)

Function

116.

What is the output of the given code?

a)

10 20 10

b)

10

c)

20

d)

10 20

117.
What will print?
a)
4
b)
5
c)
7
d)
an error message
118.
What will print?
a)
4
b)
5
c)
nothing
d)
an error message
119.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
120.
What will print?
a)
5
b)
6
c)
3 2
d)
an error message
121.
What will print?
a)
nothing
b)
sayHi()
c)
an error message
d)
hi there
122.
Which of the following best describes the order in which these lines are processed in Python?
a)
4, 1, 2
b)
4, 2, 1
c)
1, 2, 3, 4
d)
3, 1, 2
123.
What will print ?
a)
cats eat mice
b)
mice get away
c)
unknown
d)
error message
124.

      Predict the output

a)

stop

slow

go

b)

slow

c)

None

d)

go

125.

Predict the output.

Note: end=' ' is a single space.

(a)  

126.

Choose the correct function declaration of  fun1() so that we can execute the following function call successfully:

fun1(25, 75, 55)

fun1(10, 20)

a)

def fun1(**kwargs)

b)

No, it is not possible in Python

c)

 def fun1(args*)

d)

def fun1(*data)

127.

Select which is true for Python function

a)

A Python function can return only a single value

b)

A function can take an unlimited number of arguments

c)

A Python function can return multiple values

d)

Python function doesn’t return anything unless and until you add a return statement

128.

Predict the output.

Note: end= ' ' is a single space.

a)

20 20

b)

NameError

c)

20 NameError

d)

Can't say

129.

Predict the output.

Note: end=' ' is a single space

a)

('cls', 'XII') ('test', 'UT1')

b)

'cls' 'test'

c)

'XII' 'UT1'

d)

{'cls': 'XII'} {'test': 'UT1'}

130.

What is the output of the add() function call

a)

15

b)

8

c)

(8,7)

d)

Syntax Error