Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 87 - 2625 PortGPt V2.1
P. 87

    String (str)             It    represents      alphanumeric string x=            Coding, Fruit,
                                               characters and  stores sequence  'Orange'               Orange123
                                               of characters.
                                              It is used for combination  of
                                               any character  which  appears
                                               on  keyboard  (letters,  numbers,
                                               symbols).
                                              In python string variables can be
                                               declared either by  single quotes
                                               or double quotes or triple quotes.

                      Boolean (bool)          It represents logical values.           bool x= false; TRUE, FALSE
                                              Only  boolean type  values can be
                                               stored, i.e., 'true (1)' or 'false (0)'.
                                              It is a subtype of integer data type.

                                                                                                           Critical Thinking

                      Example 1:  Write a pseudocode  to declare the  different  types  of
                      variables, assign them an appropriate value and then get the values
                      as an output.

                     Solution:
                     Program Start

                     Function Main
                     Declare

                     Declare Integer a
                     Declare Float b
                     Declare Char d

                     Declare String e
                     Declare Boolean f
                     Assign

                     Assign a = 1567
                     Assign b = 1. 567

                     Assign d = 'y'
                     Assign f = 'Hello world'
                     Assign e = false
                     Use

                                                                                           Variables Using Block Coding  85

| 82 83 84 85 86 87 88 89 90 91 92 |