ord()
min()
chr()
any()
reverse(l)
list(reverse[(l)])
reversed(l)
list(reversed(l))
divmod()
all()
float()
ord(‘ ‘)
ord(”)
ord(“”)
What will be the output of the following Python function?
len(["hello",2, 4, 6])
4
3
Error
6
number of arguments
number of arguments + 1
number of arguments – 1
none of the mentioned
What will be the output of the following Python code?
def foo(k): k[0] = 1 q = [0] foo(q) print(q)
[0]
[1]
[1, 0]
[0, 1]
one-star followed by a valid identifier
one underscore followed by a valid identifier
two stars followed by a valid identifier
two underscores followed by a valid identifier
zero
one
zero or more
one or more
def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])
3 1
1 3
error
def foo(): return total + 1 total = 0 print(foo())
0
1
def foo(): total += 1 return total total = 0 print(foo())
def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
True
False
None
one star followed by a valid identifier
getopt
os
getarg
main
identifier followed by an equal to sign and the default value
identifier followed by the default value within backticks (“)
identifier followed by the default value within square brackets ([])
identifier
def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
[3,2,4]
[2,3,4]
[3,4,2]
list
set
dictionary
tuple