Robotics & Artificial Intelligence
Assertion (A): When the user defines a function of his/her own and use it in the program to perform a specific task, it is known as user defined function.
Reason (R): The types of functions viz. built-in functions and modules are also known as user defined functions because they are not defined by the system developers. Thus, it is not necessary that the system developers are only authorised for creating a function.
Based on the above discussion, choose an appropriate statement from the options given below:
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true and R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
- Both A and R are false.
Python Functions
2 Likes
Answer
A is true but R is false.
Reason — The assertion is correct because when a user defines a function of his/her own to perform a specific task, it is called a user-defined function. However, the reason is false because built-in functions and modules are defined by the system developers (language creators), not by the users. They are not user-defined functions.
Answered By
3 Likes
Related Questions
Predict the output of the following code:
def Sum(a, b): return a+5, b*5 # main program result = Sum(4, 5) print(result)Predict the output of the following code:
def Disp_Max(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') Disp_Max(22, 14)The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The following program is designed to generate next five terms of the Fibonacci series, excluding 0 and 1 (i.e., first two terms of the series). The incomplete user-defined program is given as under:
def Fibo_Series(): a = 0 b = 1 count = ........... # Line 1 while(count <= ............): # Line 2 c = a + b print(.............) # Line 3 a = ............. # Line 4 b = c count = count + 1 # main program Fibo_Series()Now, complete the above program to generate next five numbers of the series as 1, 2, 3, 5, 8.
Write a user-defined function
def Circle()to input radius of a circle from the user. The program calculates area and circumference inside the function. Finally, it returns the values to main program to display the result.