Quiz: Python Part-1

To View Tricks: Login Required

Number of Questions: 37

Question: 6 -

Which character is used in Python to make a single line comment?

Options:
  1. #

  2. !

  3. /

  4. //

  5. Answer:

    #

    Solution not available.

Question: 7 -

Which of the following statements is correct in this python code?

class Name:  
    def __init__(javatpoint):  
        javajavatpoint = java  
name1=Name("ABC")  
name2=name1  

Options:
  1. All of the above

  2. Both name1 and name2 will have reference to two different objects of class Name

  3. It will throw the error as multiple references to the same object is not possible

  4. id(name1) and id(name2) will have same value

  5. Answer:

    id(name1) and id(name2) will have same value

    Solution:

    "name1" and "name2" refer to the same object, so id(name1) and id(name2) will have the same value.


Question: 8 -

What is the method inside the class in python language?

Options:
  1. Argument

  2. Attribute

  3. Object

  4. Function

  5. Answer:

    Function

    Solution:

    Function is also known as the method.


Question: 9 -

Why does the name of local variables start with an underscore discouraged?

Options:
  1. It confuses the interpreter

  2. It indicates a private variable of a class

  3. To identify the variable

  4. None of these

  5. Answer:

    It indicates a private variable of a class

    Solution:

    Since there is no concept of private variables in Python language, the major underscore is used to denote variables that cannot be accessed from outside the class.


Question: 10 -

Which of the following statements is correct regarding the object-oriented programming concept in Python?

Options:
  1. Both objects and classes are real-world entities

  2. All of the above

  3. Classes are real-world entities while objects are not real

  4. Objects are real-world entities while classes are not real

  5. Answer:

    Objects are real-world entities while classes are not real

    Solution not available.