Python Functions

Last Updated :
Discuss
Comments

Question 1

What will be the output of the following code :

Python
print(type(type(int))) 


  • <class 'int'>

  • <class 'type'>

  • <class 'object'>

  • TypeError

Question 2

What is the output of the following code :

python
li = ['a', 'b', 'c', 'd'] print("".join(li)) 
  • Error

  • None

  • abcd

  • [‘a’,’b’,’c’,’d’]

Question 3

What is the output of the following segment :

Python
print(chr(ord('A'))) 

  • A

  • B

  • a

  • Error

Question 4

What is the output of the following program :

python
y = 8 z = lambda x : x * y print(z(6)) 
  • 48

  • 14

  • 64

  • None of the above

Question 5

What is called when a function is defined inside a class?

  • Module

  • Class

  • Another Function

  • Method

Question 6

Which of the following is the use of id() function in python?

  • Id returns the identity of the object

  • Every object doesn’t have a unique id

  • All of the mentioned

  • None of the mentioned

Question 7

What is the output of the following program :

python
def func(a, b=[]): b.append(a) return b print(func(1)) print(func(2)) 
  • [1]
    [2]


  • [1]
    [1, 2]


  • [1]
    [1]


  • None of the above

Question 8

Suppose li is [3, 4, 5, 20, 5, 25, 1, 3], what is li after li.pop(1)?

  • [3, 4, 5, 20, 5, 25, 1, 3]

  • [1, 3, 3, 4, 5, 5, 20, 25]

  • [3, 5, 20, 5, 25, 1, 3]

  • [1, 3, 4, 5, 20, 5, 25]

Question 9

time.time() returns ________

  • The current time as a string formatted as "HH:MM:SS".

  • The current time in milliseconds since January 1, 1970 UTC (Unix epoch).

  • The current time in seconds (including fractions) since January 1, 1970 UTC (Unix epoch).

  • The system’s local time in seconds since midnight.



Question 10

What will be the output of the following code?

Python
def outer(): x = 10 def inner(): nonlocal x x += 5 return x return inner closure = outer() print(closure()) print(closure()) 


  • 15
    20


  • 15
    15


  • 10
    15


  • 5
    5


There are 10 questions to complete.

Take a part in the ongoing discussion