Function parameters
Parameters are the value(s) provided in the parenthesis when we write function header. These are the values required by function to work. Let‟s understand this with the help of function written for calculating area of circle.
radius is a parameter to function area.
If there is more than one value required by the function to work on, then, all of them will be listed in parameter list separated by comma.
Arguments are the value(s) provided in function call/invoke statement. List of arguments should be supplied in same way as parameters are listed. Bounding of parameters to arguments is done 1:1, and so there should be same number and type of arguments as mentioned in parameter list.
Example
of argument in function call
>>> area (5)
5 is an argument. An argument can be constant, variable, or expression.
Qus. 1 : <p>What will be the output of the following Python code?</p><pre>def unpack(a,b,c,d):<br> print(a+d)<br>x = [1,2,3,4]<br>unpack(*x)</pre>
- Error
- [1,4]
- [5]
- 5
Qus. 2 : <p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">def foo(k): <br></span><span style="font-size: 14px; white-space: normal;"><span style="white-space:pre"> </span>k[0] = 1 <br></span><span style="font-size: 14px;">q = [0] <br></span><span style="font-size: 14px;">foo(q) <br></span><span style="font-size: 14px;">print(q)</span></pre>
- [0]
- [1]
- [1, 0]
- [0, 1]
Qus. 3 : <p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">def foo(fname, val):<br></span><span style="font-size: 14px;"> print(fname(val))<br></span><span style="font-size: 14px;">foo(max, [1, 2, 3])<br></span><span style="font-size: 14px;">foo(min, [1, 2, 3])</span></pre>
- 3 1
- 1 3
- error
- none of the mentioned
Qus. 4 : <p>How many numbers will be printed by the following code?</p><pre>def fun(a,b):<br> for x in range(a,b+1):<br> if x%3==0:<br> print(x,end=" ")<br>fun(100,120)</pre>
- 7
- 8
- 6
- 9
Qus. 5 : <p>What will be the output of the following Python code?</p><pre><span style="font-size: 12.6px;">example = "helle"
print(example.rfind("e"))</span><br></pre>
- 1
- 2
- 4
- 5
Qus. 6 : <p>What is the output of the following</p><pre style="font-size: 12.6px; letter-spacing: 0.14px;">y='klmn'<br>for i in range(len(y)):<br> print(y)</pre>
- klmn klmn klmn klmn
- k
- kkk
- None of the these
Qus. 7 : <p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">x='abcd'<br></span><span style="font-size: 14px;">for i in x:<br></span><span style="font-size: 14px;"> print(i.upper())</span></pre><div><br></div><p><br></p>
- a BCD
- abcd
- error
- A B CD
Qus. 8 : A statement is used when a statement is required syntactically but you do not want any code to execute.
- break
- pass
- continue
- none of these
Qus. 9 : What is a variable defined outside a function referred to as ?
- A static variable
- A global variable
- A local variable
- An automatic variable
Qus. 10 : what is Lambda function in python
- A built-in Python function
- A one-line anonymous function
- Lambda is a function in python but user can not use it.
- None of the above
Qus. 11 : Which of the following function headers is correct ?
- def fun (a = 2, b = 3, c)
- def fun(a = 2, b, c = 3)
- def fun(a, b = 2, c = 3)
- def fun(a, b, c = 3, d)
Qus. 12 : Which one of the following is the correct way of calling a function?
- function_name()
- call function_name()
- ret function_name()
- function function_name()
Qus. 13 : <p>find the output of following code:</p><pre><span style="font-size: 14px;">def add(a,b):<br></span><span style="font-size: 14px;"> return(a+b)<br></span><span style="font-size: 14px;">print(add(3,4))</span></pre>
- 4
- 7
- 9
- 8
Qus. 14 : ____ keyword used for function in python
- fun
- function
- def
- define
Qus. 15 : def keyword use for?
- Define keyword in python
- Define variable in python
- Define function in python
- All of the above
Qus. 16 : Which keyword is used for function in Python language?
- function
- def
- fun
- define
Programs
Python program to convert decimal into other number systems
View Solution
python program that generates six random numbers in a sequence created with start stop step
View Solution
python program to create a function to calculate factorial value
View Solution
Python program to find the sum of factorial upto n terms using function
View Solution
python program to create a function for reverse the number
View Solution
Python program to check number is Palindrome or not using function
View Solution
Python program to create a function for calculating sum of digit
View Solution
Python program to create recursive function to find factorial
View Solution
python function to accept 2 number and return addition subtraction multiplication and division
View Solution
python function to accept number of days and return week and days to its equivalent
View Solution
python function to extract the day month year from given date
View Solution
Python function to find the sum of all numbers between 100 and 500 which are divisible by 2
View Solution
Python function to get two matrices and multiply them
View Solution
python recursive function to find the sum of digits
View Solution
python recursive function to print the reverse of number
View Solution
Write a function with name dividebyfive which generate and prints a random integer number from the range 0 to 100 and then return True if the randomly generated number is divisible by 5, and False otherwise.
View Solution