Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

11 Python Interview Questions 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

11 Python Interview Questions 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

iNeuron Intelligence Pvt Ltd

1. How to Check whether the Given Year is Leap Year or Not.


Ans-

2. Write a python program to Print Fibonacci Series.

3. Write a Python Program to Check Vowel or Consonant.

Page 2 of 11
iNeuron Intelligence Pvt Ltd

4. Which statement is correct?

A. List is immutable && Tuple is mutable


B. List is mutable && Tuple is immutable
C. Both are Mutable.
D. Both are Immutable
Ans : B

ExplanaRon: List is mutable and Tuple is immutable. A mutable data


type means that a python object of this type can be modified. An
immutable object can't. So, OpRon B is correct.

5. To create a class, use the keyword?

A. new
B. except
C. class
D. object
Ans: C

ExplanaRon: To create a class, use the keyword class

Page 3 of 11
iNeuron Intelligence Pvt Ltd

6. All classes have a funcRon called?

A. __init__
B. __init__()
C. init
D. init()

Ans: B

ExplanaRon: All classes have a funcRon called __init__(), which is


always executed when the class is being iniRated.

7. The __________ parameter is a reference to the current instance


of the class, and is used to access variables that belong to the class.

A. __init__()
B. self
C. both A and B
D. None of the above

Ans: B

ExplanaRon: The self-parameter is a reference to the current instance


of the class, and is used to access variables that belong to the class.

8. You can delete properRes on objects by using the ______ keyword.

A. delete
B. dedl

Page 4 of 11
iNeuron Intelligence Pvt Ltd

C. del
D. drop

Ans: C

ExplanaRon: You can delete properRes on objects by using the del


keyword

9. A variable that is defined inside a method and belongs only to the


current instance of a class is known as?

A. Inheritance
B. Instance variable
C. FuncRon overloading
D. InstanRaRon

Ans: B

ExplanaRon: Instance variable: A variable that is defined inside a


method and belongs only to the current instance of a class.

10. A class variable or instance variable that holds data associated


with a class and its object is known as?

A. Class variable
B. Method
C. Operator overloading
D. Data member

Page 5 of 11
iNeuron Intelligence Pvt Ltd

Ans: D

ExplanaRon: Data member: A class variable or instance variable that


holds data associated with a class and its objects.

11. What is setacr() used for?

A. To set an acribute
B. To access the acribute of the object
C. To check if an acribute exists or not
D. To delete an acribute

Ans: A

ExplanaRon: setacr (obj, name, value) is used to set an acribute. If


acribute doesn’t exist, then it would be created.
12. What will be output for the following code?

class test:
def __init__(self,a):
self.a=a

def display(self):
print(self.a)
obj= test ()
obj. display ()

Page 6 of 11
iNeuron Intelligence Pvt Ltd

A. Runs normally, doesn’t display anything


B. Displays 0, which is the automaRc default value
C. Error as one argument is required while creaRng the object
D. Error as display funcRon requires addiRonal argument

Ans: C
ExplanaRon: Since, the __init__ special method has another
argument a other than self, during object creaRon, one argument is
required. For example: obj=test(“Hello”)

13. ___ represents an enRty in the real world with its idenRty and
behaviour.

A. A method
B. An object
C. A class
D. An operator
View Answer
Ans- B

ExplanaRon: An object represents an enRty in the real world that can


be disRnctly idenRfied. A class may define an object.

14. Which of the following is correct with respect to OOP concept in


Python?

Page 7 of 11
iNeuron Intelligence Pvt Ltd

A. Objects are real world enRRes while classes are not real.
B. Classes are real world enRRes while objects are not real.
C. Both objects and classes are real world enRRes.
D. Both object and classes are not real.
Ans: A

ExplanaRon: In OOP, classes are basically the blueprint of the objects.


They does not have physical existence.

15. In python, what is method inside class?

A. acribute
B. object
C. argument
D. funcRon

Ans: D

ExplanaRon: In OOP of Python, funcRon is known by "method".

16. Which one of the following is correct?

A. In python, a dicRonary can have two same keys with different


values.
B. In python, a dicRonary can have two same values with different
keys
C. In python, a dicRonary can have two same keys or same values
but cannot have two same key-value pair
D. In python, a dicRonary can neither have two same keys nor two
same values.
Page 8 of 11
iNeuron Intelligence Pvt Ltd

Ans: B

ExplanaRon: In python, a dicRonary can have two same values with


different keys.

17. What will be the following Python code?

dict1={"a":10,"b":2,"c":3}

str1=""

for i in dict1:

str1=str1+str(dict1[i])+" "

str2=str1[:-1]

print(str2[::-1])

A. 3, 2

B. 3, 2, 10

C. 3, 2, 01

D. Error

Ans: C

ExplanaRon: 3, 2, 01 will be the following Python code output.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

18. Write a Python Program to Find Factorial of a Number.

19. What are operators?


Ans-Operators are required to perform various operaRons on data.
They are special symbols that are required to carry out arithmeRc
and logical operaRons. The values on which the operator operates
are called operands.
So, if we say 10/5=2
Here ‘/’ is the operator that performs division and 10 and 5 are the
operands. Python has following operators defined for various
operaRons:
a) ArithmeRc Operators
b) RelaRonal Operators
c) Logical Operators
d)Assignment Operators
e) Bitwise Operators
f) Membership Operators
g) IdenRty Operators

20. What are ArithmeRc operators? What are various types of


arithmeRc operators that we can use in python?

Page 10 of 11
iNeuron Intelligence Pvt Ltd

Ans- They are used to perform mathemaRcal funcRons such as


addiRon, subtracRon, division, and mulRplicaRon. Various types of
arithmeRc operators that we can use in Python are as follows:

Page 11 of 11

You might also like