-
Notifications
You must be signed in to change notification settings - Fork 4
/
more_about_function.py
39 lines (28 loc) · 964 Bytes
/
more_about_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 22 01:48:42 2021
@author: mjach
"""
# example of function with arguments
def greeting(name, greeting):
print(f'{name}, {greeting}')
greeting('Mohammed', 'Good Morning !!')
#example of default value passing with a argument
def greeting_with_default_value(name = 'Mohammed', greeting= 'Good Night'):
print(f'{name}, {greeting}')
#calling function
greeting_with_default_value()
#exmple of getting error when function not getting required positional argument.
def greeting(name, greeting):
print(f'{name}')
#calliong function
greeting('Mohammed')
# variable scopes in python
def python_version_info():
python_version = '3.9'
print(f'Python version info inside the function : {python_version}')
# calling the function
python_version_info()
# example of getting error using function variable
# outside the function
#print(f'Python version info outside the function : {python_version}')