You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling a function in Python is similar to other programming languages, using the function name, parenthesis (opening and closing) and parameter(s). See the syntax, followed by an example.
20
20
21
21
### Syntax
22
-
```
22
+
```python
23
23
function_name(arg1, arg2)
24
24
```
25
25
### Example :
26
-
```
26
+
```python
27
27
defavg_number(x, y):
28
28
print("Average of ",x," and ",y, " is ",(x+y)/2)
29
29
avg_number(3, 4)
@@ -42,15 +42,15 @@ Average of 3 and 4 is 3.5
42
42
## Function without arguments :
43
43
44
44
The following function has no arguments.
45
-
```
45
+
```python
46
46
deffunction_name() :
47
47
statement_1
48
48
statement_2
49
49
....
50
50
```
51
51
### Example :
52
52
53
-
```
53
+
```python
54
54
defprintt():
55
55
print("I Love CodeCell")
56
56
print("I Love CodeCell")
@@ -73,7 +73,7 @@ I Love CodeCell
73
73
## The Return statement in function
74
74
75
75
In Python the return statement (the word return followed by an expression.) is used to return a value from a function, return statement without an expression argument returns none. See the syntax.
76
-
```
76
+
```python
77
77
deffunction_name(argument1, argument2, ...) :
78
78
statement_1
79
79
statement_2
@@ -85,7 +85,7 @@ function_name(arg1, arg2)
85
85
### Example :
86
86
87
87
The following function returns the square of the sum of two numbers.
88
-
```
88
+
```python
89
89
defnsquare(x, y):
90
90
return (x*x +2*x*y + y*y)
91
91
print("The square of the sum of 2 and 3 is : ", nsquare(2, 3))
0 commit comments