Posts

Showing posts with the label Python - Writing Programs

Python Programming Language - Writing Programs

Image
Python programs consist of a set of instructions that are placed on new lines. For example: print( 5 + 6 ) print( "Hi Rick" ) 1. Indentation   Indentation plays a significant role in defining statement blocks in Python. This is a means of informing a Python interpreter that the group of statements belongs to a specific code block. Incorrectly indented is actually makes an error. For example, in the following case we will get an error, although the code will be almost the same as above: print( 5 + 6 )  print( "Hi Rick" ) Error: File "c:\Users\91807\Pictures\python_examples\helloworld.py", line 2     print("Hi Rick") IndentationError: unexpected indent Therefore, it is worth placing new instructions at the beginning of the line. However, it is worth considering that some program constructs may consist of several lines. For example, the conditional construction 'if': if ( 3 < 6 ):     print( "Three is less than Six" ) In this