Q31. What all are logical operators in Python?

Ans: There are three logical operators in Python and, or and not. See example below

-          a>0 and a<10 # This condition is true only if a is greater than 0 and less than 10 . If a=100 than it will return false

 

-          a>0 or a<10 # this condition will return true, if either a is greater than 0 or less than 10 e.g. a=100 than also it will return true.

 

-          not (10 >100) # It will return true. Because first 10 >100, it means it is false but we are negating this condition. Hence, it will become true.

 

Q32. What is recursion?

Ans: A function calling itself. If you don’t have a base condition (to break the recursion). It can be infinite call which can lead your program to run indefinitely and then finally crash.

 

Q33. What do you mean by dead code?

Ans: A part of the code, which is never executed is known as dead code. This is generally written after the return statement and will never be executed.

 

 

 

Q34. What is the length of empty string?

Ans: Length of empty string will always be 0 and it will be represented as ‘’.

 

Q35. What does it mean string is an immutable object?

Ans : String is considered an immutable object because. Once, you create it you cannot change its value.

 

A=’Amit’

a.replace(‘A’, ‘S’) # this will not work and give error.

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