Page 358 - Informatics_Practices_Fliipbook_Class12
P. 358

99.  What is the difference between an expression and a statement in Python?

         Ans.   S.No.                Expression                                     Statement

                       An expression is a combination of symbols,  A  statement  is  defined  as  any  programming
                1
                       operators and operands.                   instruction given in Python as per the syntax.
                2      An expression represents some value.      A statement is given to execute a task.
                                                                 A statement may or may not return a value as the
                       The  outcome  of  an  expression  is  always  a
                3                                                result.
                       value, for example, 3*7 + 10 is an expression.
                                                                 print("Hello")  is a statement.

         100.  What are mutable data types in Python?

         Ans. Mutable data types in Python are data types that can be modified after creation. Some common examples of
              mutable data types in Python include lists, dictionaries, and sets.

         101.  What is the default value of end parameter in print() function?
         Ans. By default, the value of this parameter is '\n', i.e. the new line character.

         102.  What is the purpose of a break statement?

         Ans. The break statement in Python is used to exit from a loop prematurely. It is typically used within loops (such as
              for or while loops) to immediately terminate the loop's execution, even if the loop's condition or iteration hasn't
              naturally completed.

         103.  What is a dictionary?
         Ans. A Python dictionary is a collection of key-value pairs. The elements in a dictionary are indexed by keys which
              must be unique.

         104.  What is the purpose of using update() method with dictionary?
         Ans. The update() method modifies or updates the dictionary with the elements from another dictionary or from
              another sequence of key-value pairs.

         105.  What types of tokens are allowed in Python?
         Ans. The types of tokens are as follows:

              • Keywords
              • Identifiers

              • Literals
              • Operators

              • Delimiters
         106.  Can list used as keys in Python dictionaries? Justify your answer.
         Ans. No,  we  cannot  use  lists  as  keys  of  dictionary  because  lists  are  mutable  and  keys  in  the  dictionary  are
              immutable.

         107.  What is the difference between else and elif construct of if statement?
         Ans. The elif construct in an if statement is used to check additional conditions after the initial if condition. If the
              if condition is not met, the elif condition(s) are evaluated. If any elif condition is met, the corresponding
              block of code is executed.




          344  Touchpad Informatics Practices-XII
   353   354   355   356   357   358   359   360   361   362   363