Problem Solving and Python Programming: UNIT III: Control Flow, Functions, Strings

Multiple Choice Questions

Control Flow, Functions, Strings | Engineering Python Programming

Engineering Python : UNIT III : Control Flow, Functions, Strings : Anna University Multiple Choice Questions & Answers

Multiple Choice Questions

Q. 1 In Python control structure

a. defines the data structures

b. input and output statements

c. controls the order of execution of statements

d. all of the above

Ans : c. controls the order of execution of statements

 

Q. 2 Which of the following is correct statement ?

a. if  > 10:

b. if (a > = 10)

c. if (a = > 10 )

e. None of these

Ans : a. if  > 10:

 

Q. 3 Which of the keyword is used to add an alternative condition to an if statement?

a. else if

b. elseif

c. elif

d. All of the above

Ans : c. elif

 

Q. 4 Which of the following is not used as loop in Python ?

a. for

b. while

c. do-while

d. None of these

Ans : c. do-while

 

Q. 5 Which of the following will check if x is equal to y ?

a. if x = y:

b. if x= =y:

c. if x= = = y:

d. if x = = y

Ans : b. if x= =y:

 

Q. 6 In Python program if one loop is used inside another loop then it is called

a. if-else

b. foreach

c. nested

d. while

Ans : c. nested

 

Q. 7 The _ statement is null operation.

a. break

b. exit

c. return

d. pass

Ans : d. pass

 

Q. 8 Does Python have switch case statement

a. yes

b. no

c. none of these

Ans : b. no

 

Q. 9 In Python the continue statement is used in

a. while loop

b. switch

c. for

d. both a and c

Ans : d. both a and c

 

Q. 10 What will be the output of this program ?

i = [10, 11, 12, 13]

for i[-2] in i:

print(i[-2])

a. 10 11 11 12

b. 10 11 11.13

c. 10 8 6 4

d. Syntax Error

Ans : b. 10 11 11.13

 

Q. 11 Which keyword is to use for function ?

a. define

b. fun

c. def

d. function

Ans : c. def

 

 

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

a. None

b. 0

c. Null

d. 1

Ans : a. None

 

 Q.13 Which of the following is a correct way of defining the function ?

a. def function function_name():

b. declare function function_name():

c. def function_name():

d. declare function_name():

Ans : c. def function_name():

 

Q. 14 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

Ans : d. Both a and b

 

Q. 15 What is the output of the following code

def add(a, b):

return a+5, b+5

result = add(10, 20)

print(result)

a. 40

b. (15 25)

c. 15

d. 25

Ans : b. (15 25)

 

 

Q. 16 What will be the output of the following code

def fun(num):

return num + 25

fun(10)

print(num)

a. 35

b. 10

c. num

d. Error

Ans : d. Error

 

Q. 17 What is a recursive function ?

a. A function that calls other function.

b. A function which calls itself.

c. Both a and b

d. None of the above

Ans : b. A function which calls itself.

 

Q. 18 Which one of the following is the correct way of calling a function ?

a. function_name()

b. call function_name()

c. ret function_name()

d. function function_name()

Ans : a. function_name()

 

Q. 19 What will be the output of the following code ?

def test(a, b = 5):

print(a, b)

test(-3)

a. a b

b. -3

c. -3 5

d. 5

Ans : c. -3 5

 

Q. 20 What will the below Python code will return ?

list1 = [1,2,3,4]

str1 = "2" for i in list1:

str1= str1 + i

print(str1)

a. 21234

b. 12

c.12

d. Error

Ans : d. Error

 

Problem Solving and Python Programming: UNIT III: Control Flow, Functions, Strings : Tag: Engineering Python : Control Flow, Functions, Strings | Engineering Python Programming - Multiple Choice Questions