adplus-dvertising

Welcome to the Miscellaneous topics in Python MCQs Page

Dive deep into the fascinating world of Miscellaneous topics in Python with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Miscellaneous topics in Python, a crucial aspect of Python. In this section, you will encounter a diverse range of MCQs that cover various aspects of Miscellaneous topics in Python, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Python.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Miscellaneous topics in Python. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Python.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Miscellaneous topics in Python. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Miscellaneous topics in Python MCQs | Page 6 of 7

Q51.
Fill in the line of code for calculating the factorial of a number.
def fact(num):
    if num == 0: 
        return 1
    else:
        return _____________________
Discuss
Answer: (a).num*fact(num-1)
Q52.
What is the output of the following piece of code?
def test(i,j):
    if(i==0):
        return j
    else:
        return test(i-1,i+j)
print(test(4,7))
Discuss
Answer: (a).13
Q53.
What is the output of the following code?
l=[]
def convert(b):
    if(b==0):
        return l
    dig=b%2
    l.append(dig)
    convert(b//2)
convert(6)
l.reverse()
for i in l:
    print(i,end="")
Discuss
Answer: (b).110
Discuss
Answer: (d).A function where the recursive call is the last thing executed by the function
Q55.
Observe the following piece of code?
def a(n):
    if n == 0:
        return 0
    else:
        return n*a(n - 1)
def b(n, tot):
    if n == 0:
        return tot
    else:
        return b(n-2, tot-2)
Discuss
Answer: (c).b() is tail recursive but a() isn’t
Discuss
Answer: (d).Every recursive function must have a return value
Q57.
What is the output of the following piece of code?
def fun(n):
    if (n > 100):
        return n - 5
    return fun(fun(n+11));
 
print(fun(45))
Discuss
Answer: (b).100
Q58.
Recursion and iteration are the same programming approach. True or False?
Discuss
Answer: (b).False
Discuss
Answer: (a).Program gets into an infinite loop
Q60.
The output of the code shown below and state the type of copy that is depicted:
l1=[2, 4, 6, 8]
l2=[1, 2, 3]
l1=l2
l2
Discuss
Answer: (c).[1, 2, 3], shallow copy
Page 6 of 7

Suggested Topics

Are you eager to expand your knowledge beyond Python? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!