Choose the correct answerWhat will be the output of the following program?def func(a, **b): print(type(b))func('python', A = '1', B = '2')Select all the correct statements given below.Options<class 'int'><class 'tuple'><class 'dict'><class 'str'>
Question
Choose the correct answerWhat will be the output of the following program?def func(a, **b): print(type(b))func('python', A = '1', B = '2')Select all the correct statements given below.Options<class 'int'><class 'tuple'><class 'dict'><class 'str'>
Solution
The correct answer is <class 'dict'>.
Here's why:
In Python, **b in function arguments is used to pass variable length non-keyword argument. This means you can pass any number of arguments with their keys and Python will convert those keys and values in dictionary inside function. So, the type of 'b' will be <class 'dict'>.
Similar Questions
Choose the correct answerWhat will be the output of the following program?def fun(): try: print(1) finally: print(2)fun()Select all the correct statements given below.Options211221
Select the correct answerWhat will be the output of the following Python code?def codetantra(one, *two): print(type(two))codetantra(6,7,8,9)Options<class 'tuple'><class 'int'><class 'dict'>An exception is thrown
Select the correct answerWhat will be the output of the following Python code?def cb(a): return a * a * a a = cb(3) print(a)Options927303
What will be the output of the following Python code?def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3, 7)func(25, c = 24)func(c = 50, a = 100)1 pointOption 1Option 2Option 3None
Select the correct answerWhat will be the output of the following Python code?def type1(p, **q): print(type(q))type1('letters',M='1',N='2')OptionsTupleStringDictionaryAn exception is thrown
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.