Python Functions (original) (raw)
What will be the output of the following code :
Python `
print(type(type(int)))
`
What is the output of the following code :
python `
li = ['a','b','c','d'] print("".join(li))
`
What is the output of the following segment :
Python `
print(chr(ord('A')))
`
What is the output of the following program :
python `
y = 8 z = lambda x : x * y print(z(6))
`
What is called when a function is defined inside a class?
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
What is the output of the following program :
python `
import re s = 'horses are fast'
regex = re.compile(r'(?P\w+) (?P\w+) (?P\w+)') matched = re.search(regex, s)
if matched: print(matched.groupdict())
`
- {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}
- (‘horses’, ‘are’, ‘fast’)
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]
time.time() returns ________
- the current time in milliseconds
- the current time in milliseconds since midnight
- the current time in milliseconds since midnight, January 1, 1970
- the current time in milliseconds since midnight, January 1, 1970 GMT (the Unix time)
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())
`
There are 10 questions to complete.
Take a part in the ongoing discussion