Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 138 - 2609_Logiccode
P. 138

    21 st
                         LAB ACTIVITY                                                            Century   #Critical Thinking
                                                                                                   Skills

                         Write the output of the following programs:
                         1.  a = 4.5
                            b = 2
                            print (a//b)
                         2.    y = 10
                            y += 2
                            print(y)

                         3.  a = 4
                            b = 11
                            print(a or b)
                            print(a  > 2)

                         4.  var1 = 1
                            var2 = 2
                            var3 = 3
                            print(var1 + var2 + var3)
                         5.  a = 23
                            b = 4
                            if a > b:
                                  print("First number is greater than
                                second number")
                            else:
                                 print("Second number is greater than
                                 first number")
                         6.  num = 3.4
                            if num > 0:
                                print("Positive number")
                            elif num == 0:
                                print("Zero")
                            else:
                                print("Negative number")
                         7.  x = 31
                            if x > 10:
                              print("Above ten")
                              if x > 20:
                                print("and also above 20!")
                              else:
                                print("but not above 20.")

                         FOR THE TEACHER

                        1.  Introduce common data types such as int float string and boolean.
                        2.  Explain that comments are notes written in code for understanding.

                      136   Premium Edition-VII

| 133 134 135 136 137 138 139 140 141 142 143 |