this will explain how to create a funtion in
python and call it,if the funtion doesnot returns any value then
it will be treated as none
to view the definition of the function you can do -- ctrl + left click
def python_food():
print("Spinach is good for health")
python_food()
print (python_food())
def center_text():
width = 50
text = 'Spinach is good for health'
leftalignment = (width - len(text))//2
print(' '*leftalignment,text)
center_text()
print('='*20)
def center_text1(text):
width = 50
leftalignment = (width - len(text))//2
print(' '*leftalignment,text)
center_text1('Spinach is Good for Health')
center_text1('Excecise is goood for body')
center_text1('Life is worth living')
center_text1('Love yourself')
the below code is the text behind the print function,we can see only the basic info
not the code since this is written in C-language
def print(self, *args, sep=' ', end='\n', file=None): # known special case of print
"""
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
"""
pass
No comments:
Post a Comment