Functions Quiz 7

Share with others

Welcome to your Functions Quiz 7

Q61. Which of the following options can be the output for the following code?

import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
       x = random.randint(1,3)
       print(List[x],end="#")

Q62. What will be the output of the following code?

x = 3
def myfunc():
      global x
      x+=2
     print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')

Q63. Which of the following components are part of a function header in Python?

i. function name
ii. return statement
iii. parameter list
iv. def keyword

Q64. Which of the following function headers is correct?

Q65. Which of the following is the correct way to call a function?

Q66. What will be the output of the following Python code?

def add (num1, num2):
       sum = num1 + num2
sum = add(20,30)
print(sum)

Q67. What will be the output of the following code?

def my_func(var1=100, var2=200):
      var1 += 10
      var2 = var2 - 10
      return var1+var2
print(my_func(50),my_func())

Q68. What will be the output of the following code?

value = 50
def display(N):
     global value
     value = 25
     if N%7==0:
           value = value + N
    else:
           value = value - N
print(value, end="#")
display(20)
print(value)

Q69. What is the output of the following code snippet?

def ChangeVal(M,N):
     for i in range(N):
          if M[i]%5 == 0:
               M[i]//=5
          if M[i]%3 == 0:
               M[i]//=3
L = [25,8,75,12]
ChangeVal(L,4)
for i in L:
     print(i,end="#")

Q70. What will be the possible outcome of the following code:

import random

X =[1,2,3,4]

m = random.randint(0,3)

for i in range(m):

       print (X[i],"--",end=" ")


Share with others

1 thought on “Functions Quiz 7”

Leave a Reply

error: Content is protected !!