Font size
WorksheetsPython Functional Programming
Total questions: 130
Worksheet time: 1hrs 18mins
What is Python?
It is a high-level and only object-oriented programming language.
It is a low-level and general-purpose programming language.
It is a high-level and general-purpose programming language
It is a high-level and general-purpose app.
Python was created in __ by __.
2000 / Python Software Foundation
2000/ Guido Van Rossum
1991 / Guide Van Rossum
1991 / Guido Van Rossum
Python is NOT __.
faster than Java
powerful
flexible
easy-to-use
Python is dynamic.
True
False
Which type of Programming does Python support?
object-oriented programming
structured programming
functional programming
all of the mentioned
Which of the following is the correct extension of the Python file?
.python
.pi
.py
.p
Which of the following best describes the Python and keyword
It's a logical operator
It's used to create an alias
It's used for debugging
It's used to break out of a loop
Which of the following best describes the Python break keyword
It's a logical operator
It's used to create an alias
It's used for debugging
It's used to break out of a loop
Which of the following best describes the Python def keyword
It's used to defined a class
It's used in conditional statements
It's used to define a function
It's used to delete an object
Which of the following best describes the Python None keyword
it's a null statement, a statement that will do nothing
It's used to create an anonymous function
It's used to define a function
It's used to represents a null value
Which of the following is a python keyword?
True
not
if
All
Which module prints all python keywords?
keyword
keywords
words
keyswords
Identify the invalid variable name
s_a_l_a_r_y
salary____
sal&ary
s1a2l3a4r5y6
Which function is used to find the type of a value?
id()
print()
type()
input()
Which operator is used for exponent?
**
*
$
^
What does the following comparison operator “==” represent in Python programming?
Equal to
Assignment
Allocation
Not equal to.
What does the following comparison operator “!=” represent in Python programming?
Equal to
Assignment
Allocation
Not equal to.
What is the result of the following condition if x = 3?
not(x < 5 and x < 10)
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
(A > B and A > C) or B < C
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
not(B < A and B < C)
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
B != A or C < A
True
False
Which of the following declarations is incorrect in python language?
xyzp = 5,000,000
x y z p = 5000 6000 7000 8000
x,y,z,p = 5000, 6000, 7000, 8000
x_y_z_p = 5,000,000
Which of the following words cannot be a variable in python language?
_val
val
try
_try
What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2
512, 64, 512
512, 512, 512
64, 512, 64
64, 64, 64
What will be the output of the following Python function?
len(["hello",2, 4, 6])
Error
6
4
3
What will be the output of the following Python code?
print("abc. DEF".capitalize())
Abc. def
abc. def
Abc. Def
ABC. DEF
What is the output?
more than 7
more than 23
spam
7
If you want to test more than one condition (chained condition), what do you use after if statement?
elif
else
ifif
else if
Which character must be at the end of the line for if?
:
;
.
{
Failure
What will be the output of the code displayed?
(a)
What is the output from the following code?
(a)
What is the output from the following code?
(a)
What is the output from the following code?
(a)
What is the output of the following code?
(a)
What is the output from the following code?
(a)
What is the output from the following code?
(a)
What is the missing line of code?
new = chr(new)
new = ord(new)
new = chr(letter)
print new
What is the missing line of code?
if new > ord('z'):
If new =< ord('z'):
if new > chr('z'):
else next:
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The equivalent of the above for loop using the while syntax would be
The above program prints
Numbers 1 to 10 in reverse order
Numbers 1 to 11 in reverse order
Numbers 1 to 10
Numbers 1 to 11
The program above prints
Numbers between 1 and 100 that are multiples of 5
Numbers between 1 and 100
Numbers between 1 and 100 divisible by 5
Numbers between 1 and 101 that are multiples of 5
The code above prints all numbers between 1 and 30 that are
not divisible by 5
divisible by 5
The program above prints the sum of
all odd numbers less than 100
all even numbers less than 100
all numbers less than 100
The program above prints the sum of all the numbers between 0 and 101 that are
alternate odd numbers
alternate even numbers
alternate numbers
The program above prints each number between 1 and 10
as many times as the number itself
10 times
11 times
The program above prints each number between 1 and 10
as many times as the number itself
10 times
11 times
How many times will 1 be printed
3
4
5
6
for i in 100 :
print ( i )
Syntax error
prints numbers 0 to 100
prints numbers 1 to 100
prints numbers 0 to 99
prints numbers 1 to 99
What is the output of the program above
10
15
18
17
16
A while loop equivalent of the for loop above is
What is the value of the variable sum after the code above executes
54
44
64
34
74
What does this program print
2 + 2 = 4
4 + 4 = 8
8 + 8 = 16
16 + 16 = 32
32 + 32 = 64
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
2 + 10 = 12
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
2 + 4 = 6
2 + 6 = 8
2 + 8 = 10
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
It displays an output
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
WHILE loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
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.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a revision program that will run through revision questions 4 times.
FOR Loop
WHILE Loop
A: Strings can be changed during execution
B. Strings can be enclosed within single, double or even triple quotes
C. Strings are immutable
A,B & C are True
A,B are True but C is False
B, C are True but A is False
A,C are True but B is False
Find the output of the following code:
>>>str1='Save Soil'
>>>str1.isalnum( )
Save Soil
True
False
Identify the string membership operators of Python
in, not in
like, not like
as, not as
between, not between
The title( ) function
assigns title
returns the title of the file
returns string in title case
Predict the output:
>>>str1="Rajathi Raja"
>>>print(str1.count('Raja'))
1
2
Error
Raja
Predict the output:
>>>saint="Thiruvalluvar"
>>>print(saint[5:])
valluvar
Thiruvalluvar
uvalluvar
Thiru
Which of the operator can be used in Strings?
+
*
Both of the above
None of the above
word = "amazing"
For the given string if we run word[2:5] what does it mean?
It will extract alphabets from index 2 to index 4
It will extract alphabets from index 2 to index 5
It will extract alphabets from position 2 to position 4
It will extract alphabets from position 2 to position 5
word = "amazing"
For the given string if we run word[2:5:2] what does 2 mean in this function?
It will pick only second alphabet
It will pick only two alphabets
It will pick every alternate alphabet
It will pick first two alphabets
Which method is used to convert a given string in Capital letters?
Capital
Upper
ConverttoUpper
Capitalize
s1="Hello"
n1=10
print(s1+n1)
What is the error in this code?
Print statement not written in quotes
Numeric value not written in quotes
colon not written after the print statement
string cannot be added to a number
s1="Hello"
s2="10"
print(s1+n1)
What is the error in this code?
String 2 written in quotes
String cannot be multiplied with a string
colon not written after print statement
Number written in quotes
Lists are?
Mutable
immutable
fruit1="kiwi"
fruit2="strawberry"
print(len(fruit1))
print(len(fruit2))
kiwi and strawberry
4
10
4 10
410
slicing string X="BOnVoyage"
print X[0:5]
BOnVoy
BOnVo
oyage
bonvo
Slicing string
x="BOnvoyage
print(x[4: ])
BOnvo
bonvo
voyage
VOYAGE
a="god help those who help themselves"
"help" in "a"
true
false
wrong out put
error
Which keyword is used for function?*
define
fun
def
function
Which of the following items are present in the function header?
function name
parameter list
return value
Both A and B
If the return statement is not used inside the function, the function will return:
0
None
Null
Arbitary value
In which part of memory does the system store the parameter and local variables of a function call?
heap
stack
Uninitialized data segment
None of the above
What will be the output of the following Python expression? round(4.576)
4.5
5
4
4.6
Which statement is correct to import all modules from the package
from package import all
from package import *
from package include all
from package include *
What is returned by math.ceil(3.4)?
3
4
4.0
3.0
What term is used to describe data passed into a function?
Variable
Loop
Constant
Parameter
Leo wants to create a function that will roll a dice. Which is the correct function definition header?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
Write the line of code that will call the function.
(a)
Write the line of code that will define the function, draw_coin
(a)
Do you call or define a function first?
call
define
Correctly rewrite this line of code!
(a)
Correctly rewrite this line of code !
(a)
Rewrite the line of incorrect code using Camel Case to make it correct!
Hint: The mistake is when the function gets called
(a)
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?
return value statement
Variable
Function definition
Parameters
What will be the output of this program?
0
1
2
3
4
The parameters could be a
Variable
Literal
Expression
Function
What is the output of the given code?
10 20 10
10
20
10 20
Predict the output
stop
slow
go
slow
None
go
Predict the output.
Note: end=' ' is a single space.
(a)
Choose the correct function declaration of fun1() so that we can execute the following function call successfully:
fun1(25, 75, 55)
fun1(10, 20)
def fun1(**kwargs)
No, it is not possible in Python
def fun1(args*)
def fun1(*data)
Select which is true for Python function
A Python function can return only a single value
A function can take an unlimited number of arguments
A Python function can return multiple values
Python function doesn’t return anything unless and until you add a return statement
Predict the output.
Note: end= ' ' is a single space.
20 20
NameError
20 NameError
Can't say
Predict the output.
Note: end=' ' is a single space
('cls', 'XII') ('test', 'UT1')
'cls' 'test'
'XII' 'UT1'
{'cls': 'XII'} {'test': 'UT1'}
What is the output of the add() function call
15
8
(8,7)
Syntax Error
