Opening Hours :7AM to 9PM
a = 1 + 2 + 3 + \ 4 + 5 + 6 + \ 7 + 8 + 9This is explicit line continuation. In Python, line continuation is implied inside parentheses ( ), brackets [ ] and braces { }. For instance, we can implement the above multi-line statement as
a = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:
colors = ['red', 'blue', 'green']
for i in range(1,11): print(i) if i == 5: breakThe enforcement of indentation in Python makes the code look neat and clean.
if True: print('Hello') a = 5 and if True: print('Hello'); a = 5both are valid and do the same thing. But the former style is clearer.
#This is a comment #print out Hello print('Hello')
"""This is also a perfect example of multi-line comments"""
def myfun(num): """Function to double the value""" return 2*numDocstring is available to us as the attribute __doc__ of the function. Issue the following code in shell once you run the above program.