Home | | Computer Science 12th Std | Passing Parameters in Functions

Python - Passing Parameters in Functions | 12th Computer Science : Chapter 7 : Core Python : Python Functions

Chapter: 12th Computer Science : Chapter 7 : Core Python : Python Functions

Passing Parameters in Functions

def function_name (parameter(s) separated by comma):

Passing Parameters in Functions

Parameters or arguments can be passed to functions

def function_name (parameter(s) separated by comma):

Let us see the use of parameters while defining functions. The parameters that you place in the parenthesis will be used by the function itself. You can pass all sorts of data to the functions. Here is an example program that defines a function that helps to pass parameters into the function.

Example:

assume w = 3 and h = 5

defarea(w,h):

return w * h

print (area (3,5))

The above code assigns the width and height values to the parameters w and h. These parameters are used in the creation of the function “area”. When you call the above function, it returns the product of width and height as output.

The value of 3 and 5 are passed to w and h respectively, the function will return 15 as output.

We often use the terms parameters and arguments interchangeably. However, there is a slight difference between them. Parameters are the variables used in the function definition whereas arguments are the values we pass to the function parameters

 

Tags : Python , 12th Computer Science : Chapter 7 : Core Python : Python Functions
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Science : Chapter 7 : Core Python : Python Functions : Passing Parameters in Functions | Python


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.