Function parameters

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><span style="font-size: 12.6px;">example = "helle" print(example.rfind("e"))</span><br></pre>

  1. 1
  2. 2
  3. 4
  4. 5
Qus. 2 : <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>&nbsp; &nbsp; print(y)</pre>

  1. klmn klmn klmn klmn
  2. k
  3. kkk
  4. None of the these
Qus. 3 : <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;">&nbsp; &nbsp; print(i.upper())</span></pre><div><br></div><p><br></p>

  1. a BCD
  2. abcd
  3. error
  4. A B CD
Qus. 4 : A statement is used when a statement is required syntactically but you do not want any code to execute.

  1. break
  2. pass
  3. continue
  4. none of these
Qus. 5 : What is a variable defined outside a function referred to as ?

  1. A static variable
  2. A global variable
  3. A local variable
  4. An automatic variable
Qus. 6 : what is Lambda function in python

  1. A built-in Python function
  2. A one-line anonymous function
  3. Lambda is a function in python but user can not use it.
  4. None of the above
Qus. 7 : Which of the following function headers is correct ?

  1. def fun (a = 2, b = 3, c)
  2. def fun(a = 2, b, c = 3)
  3. def fun(a, b = 2, c = 3)
  4. def fun(a, b, c = 3, d)
Qus. 8 : Which one of the following is the correct way of calling a function?

  1. function_name()
  2. call function_name()
  3. ret function_name()
  4. function function_name()
Qus. 9 : <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;">&nbsp; &nbsp; return(a+b)<br></span><span style="font-size: 14px;">print(add(3,4))</span></pre>

  1. 4
  2. 7
  3. 9
  4. 8
Qus. 10 : ____ keyword used for function in python

  1. fun
  2. function
  3. def
  4. define
Qus. 11 : def keyword use for?

  1. Define keyword in python
  2. Define variable in python
  3. Define function in python
  4. All of the above

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 illustrate the global variable

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


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad