Baheeg Training and Test Exam

Python intermediate Level

Score: 0 / 0 answered

Progress: 0 of 817 qs

time elap: 00:00

Question 1: What is the output of the following code?

from functools import singledispatch

@singledispatch
def fun(arg):
    return "Unknown type"

@fun.register(int)
def _(arg):
    return f"Integer: {arg}"

@fun.register(str)
def _(arg):
    return f"String: {arg}"

print(fun(10))
print(fun("hello"))
print(fun(10.5))