Page 119 - Computing E-Book Grade 7
P. 119

The City School  2021-2022




             Python Indentations


             Indentation refers to the spaces at the                   Indentation Example

             beginning of a code line. Where in other
             programming languages the indentation in               if 5 > 2

             code is for readability only, the indentation            print (”Five is
                                                                    greater than two”)
             in Python is very important. Python uses

             indentation to indicate a block of code.                                                                Programming the Computer-Python




             5.6.  Variables and Data Types                                “a”               “hello”



             A variable is nothing but a name given
             to a storage area that our programs can

             manipulate.
             A variable is a container of data in a

             computer’s memory where the computer stores                   4                   2.5
             the different types of data and this could be

             numeric or text. To create and access these
             Variable (data containers) we name them so

             we can call them in our program where it is
             necessary.


             Data can be of any type like text, numbers,
             integers, etc. A variable can store values only in one

             data type either it could be numeric or string. Python
             has no command for declaring a variable.

             Numeric data type: This data type is used to hold               Comments in Python
             numeric values like integers, or Float like decimal
                                                                         #this is comment
             numbers.
             String data type: The string is a sequence of               print(”hello world”)

             characters like a simple text “Hello World”.
             Python supports Unicode characters. Generally,

             strings are represented by either single or double-












                                                                                                                119
   114   115   116   117   118   119   120   121   122   123   124