Page 81 - Touchcode_C7_Flipbook
P. 81

Subject Enrichment

                  Example:

                      1.  Defining and assigning a value to a variable. (Text=“Orange Education”)
                      2.  Accessing the first letter of the variable. (print(Text[0]))
                      3.   Defining a second variable and joining it to the declared variable. (print(Text+Text1))


                     Integers (int) and Floats (float)

                        Integer variable represents whole numbers (zero, positive, negative value, not the
                        decimal value)/integer value).
                       Assigning non-integer value to integer type variable returns error.
                       Integer type variable holds only a single value.

                       Quotation marks cannot be used to define integers.
                       Floating point represents real numbers with decimal values or fractions.
                        Another type of floating-point number is ‘double’ data type, to store even bigger values.

                       Example of integer: x=4
                       Example of float: x= 5.1
                                              x= 9.99*8.888
                        Common arithmetic operations which can be performed with floats and integers are:
                        Addition, Subtraction, Multiplication, Division, and Modulus (Remainder).

                          Syntax to perform addition of integers and floats: x+y
                          Syntax to perform subtraction of integers and floats: x–y
                          Syntax to perform multiplication of integers and floats: x*y

                          Syntax to perform division of integers and floats: x/y
                          Syntax to perform modulus of integers and floats: x%y
                    Boolean

                       Represent logical values.
                       Stores values in Boolean type only i.e. ‘true (1)’ or ‘false (0)’.
                       Subtype of integer data type.

                       Example: b=False

                   Coding           uiz   02                                                          Critical Thinking



                    Give one word answer to the following questions:

                    a.  Data type that stores a sequence of characters in quotes.                 ...........................
                    b.  Data type which store whole numbers, which can be

                        positive or negative.                                                     ...........................



                                                                                        Hello World with Code    79
   76   77   78   79   80   81   82   83   84   85   86