/    /  Python – Interview Questions Part 8

1. When Should You Use The “Break” In Python?

Answer: A break statement is used in python to exit from a loop. Whenever the break hits in the code, the control of the program immediately exits from the body of the loop. The break statement in a nested loop causes the control to exit from the inner iterative block.

 

2. What Is The Difference Between Pass And Continue In Python?

Answer: The continue statement makes the loop to resume from the next iteration. On the contrary, the pass statement instructs to do nothing, and the remainder of the code executes as usual.

 

3. What Does The Chr() Function Do In Python?

Answer: The chr() function got re-added in Python 3.2. In version 3.0, it got removed. It returns the string denoting a character whose Unicode code point is an integer.

For example, the chr(122) returns the string ‘z’ whereas the chr(1212) returns the string ‘Ҽ’.

 

4. What Does The Ord() Function Do In Python?

Answer: The ord(char) in Python takes a string size one and returns an integer denoting the Unicode code format of the character in case of a Unicode type object, or the value of the byte if the argument is of 8-bit string type.

>>> ord(“z”)122

 

5. What Is Rstrip() In Python?

Answer: Python provides the rstrip() method which duplicates the string but leaves out the whitespace characters from the end. The rstrip() escapes the characters from the right end based on the argument value, i.e., a string mentioning the group of characters to get excluded.

 

6. What Is Isalpha() In Python?

Answer: Python provides this built-in isalpha() function for the string handling purpose.

It returns True if all characters in the string are of alphabet type, else it returns False.

 

7. What Does Join Method Do In Python?

Answer: Python provides the join() method which works on strings, lists, and tuples. It combines them and returns a united value.

 

8. What Does Title() do In Python?

Answer: Python provides the title() method to convert the first letter in each word to capital format while the rest turns to Lowercase.

#Examplestr = ‘lEaRn pYtHoN’

print(str.title())

The output:

Learn Python

 

9. What Makes The CPython Different From Python?

Answer: CPython has its core developed in C. The prefix ‘C’ represents this fact. It runs an interpreter loop used for translating the Python-ish code to C language.

 

10. What Is GIL In Python Language?

Answer: Python supports GIL (the global interpreter lock) which is a mutex used to secure access to Python objects, synchronizing multiple threads from running the Python bytecodes at the same time.