Functions Output#

  • Find the output of the following code.

  • Please don’t run the code before giving your answer.     

Question-1#

def f(x):
  return 10*x

Solution

No output.

Question-2#

def f(x):
  return 10*x

print(f(5))

Solution

50

Question-3#

def f(x, y=5):
  return x+y

print(f(2, 4))
print(f(10))

Solution

6
15

Question-4#

def func_letter():
  print('A')
  print('B')

def func_word():
  print('X')
  func_letter()

func_word()

Solution

X
A
B

Question-5#


def my_func(x):
  print('A')
  print('B')
  return x**2

print(my_func(3))

Solution

A
B
9

Question-6#

def func(a,b,c=3):
  x = a**2+b*4-c
  return x

print(func(1,5))

Solution

18

Question-7#

def my_func(x, y):
  print(x//3)
  y += 2
  print(x+y)

my_func(13,7)

Solution

4
22

Question-8#

def my_func(x, y, z):
  if x+y > 10:
    total = x+y
  else:
    total = y+z
  return total

print(my_func(2,7,4))

Solution

11

Question-9#

c = 3
def f(x,y):
  z = 6
  return x+y+z+c

print(f(1,2))
c = 5
print(f(1,2))

Solution

12
14

Question-10#

def f(x, y):
  print('x:',x)
  return x+y
    
print(f(1,2))

Solution

x: 1
3

Question-11#

def f(x=1, y=6):
  return x+y
    
print(f())

Solution

7