Q66. How is the below statement will be evaluated?

“x” in “a” , “x”

Ans : Please note that comma is not an operator. It is a separator. Hence, above statement will be evaluated as below.

 

(“x” in “a”) , “x”

 

And result will be as below

 

(False, “x”)

 

Q67. What is the value of below expression?

 

X=100

Y=20

 

Val = X if X < Y else Y

 

Ans: Here Val will have 20. Because first condition is false, which will result in Y, which is 20.

 

Q68. How will you remove the duplicate elements from the list?

Ans: It’s very simple, as we know set contain only unique values. Hence, first convert list to set and then set back to list.

 

list(set(list_with_duplicates))

 

Q69. What is a Class?

Ans : You can say, it is a user defined object. It works as a template and hold attributes and functions.

 

Learn Python in Less than 8 Hours sitting at Home/@Desk

 

Q70. What is self?

Ans: Self is a first argument of a method. A method defined as do_something(self, a, b, c) should be called as object.do_something(a, b, c) for some instance object of the class in which the definition occurs; the called method will think it is called as do_something(self, a, b, c).

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam