Page 26 - ipp11
P. 26

17.  What is None in Python?
             Ans.  Python  has one special data type called  None. It is used to indicate something that has not been
                 created yet. It represents the absence of a value or a null value.
              18.  What is the purpose of else in a loop?
             Ans.  Looping statements can have an optional else block as well. The else part is executed if the items in the
                 sequence do not match or when loop gets over.

              19.  What do you mean by comments in Python? Which symbol is used for single-line comments?
             Ans.  The non-executable statements in a Python code are called comments.
                  # symbol is used for single-line comments.
              20.  Give the code to find the address of variable ‘x’.
             Ans.  An identity function id() is used to find the address of a variable.
                  For example, to find the address of variable ‘x’, the code will be:
                     >>>id(x)indexing
              21.  What is the following statement termed as?
                     a,b,c,d = 1,2,3,4
             Ans.  Multiple Assignment Statement.
              22.  What is the difference between pop() and remove() functions?
             Ans.  pop() function removes the element from the specified index and also returns the element which was
                 removed. If no index value is provided in pop(), then the last element is deleted.
                  The remove() function is used when we know the element to be deleted but not the index of the
                 element. It does not return the deleted element.

              23.  Define input() method.
             Ans.  The purpose of an input() method is to fetch some information from the user of a program and store
                 it into a variable.
              24.  What is the default data type of input fetched from the user using input() function?
             Ans.  String or str.
              25.  What is the role of a print() function?
             Ans.  A print() method prints an expression which may be a variable’s value or string or a blank line followed
                 by a newline character (by default) to the output console.

              26.  What does the print() function add to the end of the string?
             Ans.  By default, the print() function adds a new line to the end of the string being printed.
              27.  If you don’t use the sep option with print() function, what will it print?
             Ans.  If sep is not defined, a space is printed between the values received by the print() statement.
              28.  What is the default value printed by giving end argument to print() method?
             Ans.  A new line ('\n').
              29.  What is an operator in Python?
             Ans.  An operator in Python is a token that performs some mathematical and logical operations on operands or
                 data items.
                 For example, +, –, *, /, %, >, <, >=, <=, <<, >>, &, |, ^, ==, etc.
              30.  When does a logical and operator produce True result?
             Ans.  The logical and operator evaluates to True only if both conditions/operands are True.
              31.  What is an expression? What does it constitute?
             Ans.  An operand or a combination of operands and operators, when evaluated, yields a single value called an
                 expression. The expression consists of variables, constants and functions.
              32.  What is modulo operator? Give an example.
             Ans.  The % operator is termed as modulo operator. It returns the remainder obtained by dividing one number
                 by another. For example, the command 5%2 shall return the result as 1—the remainder obtained when
                 we divide 5 by 2.


                                                           V.2
   21   22   23   24   25   26   27   28   29   30   31