My Report

Python Function Test – 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of the following refers to mathematical function?

2. Which of the following is the use of id() function in python?

3. Which are the advantages of functions in python?

4. Where is function defined?

5. What is called when a function is defined inside a class?

6. What will be the output of the following Python code?

def C2F(c):
    return c * 9/5 + 32
print C2F(100)
print C2F(0)

7. What are the two main types of functions?

8. What will be the output of the following Python code?

def power(x, y=2):
    r = 1
    for i in range(y):
       r = r * x
    return r
print power(3)
print power(3, 3)

9. What will be the output of the following Python code?

def cube(x):
    return x * x * x      
x = cube(3)    
print x

10. What will be the output of the following Python code?

def sum(*args):
   '''Function returns the sum 
   of all values'''
   r = 0
   for i in args:
      r += i
   return r
print sum.__doc__
print sum(1, 2, 3)
print sum(1, 2, 3, 4, 5)

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.