October 13, 2018

Sreekanth B

Concentrix Most Frequently Asked Python Latest Interview Questions Answers

What is the purpose of ** operator?

** Exponent − Performs exponential (power) calculation on operators. a**b = 10 to the power 20 if a = 10 and b = 20.

What is the purpose of // operator?

// Floor Division − The division of operands where the result is the quotient in which the digits after the decimal point are removed.

What is the purpose of is operator?

is − Evaluates to true if the variables on either side of the operator point to the same object and false otherwise. x is y, here is results in 1 if id(x) equals id(y).

What is the purpose of not in operator?

not in − Evaluates to true if it does not finds a variable in the specified sequence and false otherwise. x not in y, here not in results in a 1 if x is not a member of sequence y.

What is the purpose break statement in python?

break statement − Terminates the loop statement and transfers execution to the statement immediately following the loop.
Concentrix Most Frequently Asked Python Latest Interview Questions Answers
Concentrix Most Frequently Asked Python Latest Interview Questions Answers

What is the purpose continue statement in python?

Continue statement − Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

What is the purpose pass statement in python?

pass statement − The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.

How can you pick a random item from a list or tuple?

choice(seq) − Returns a random item from a list, tuple, or string.

How can you pick a random item from a range?

randrange ([start,] stop [,step]) − returns a randomly selected element from range(start, stop, step).

How can you get a random number in python?

random() − returns a random float r, such that 0 is less than or equal to r and r is less than 1.

How will you set the starting value in generating random numbers?

seed([x]) − Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.

How will you randomizes the items of a list in place?

shuffle(lst) − Randomizes the items of a list in place. Returns None.

How will you capitalizes first letter of string?

capitalize() − Capitalizes first letter of string.

How will you check in a string that all characters are alphanumeric?

isalnum() − Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.

How will you check in a string that all characters are digits?

isdigit() − Returns true if string contains only digits and false otherwise.

How will you check in a string that all characters are in lowercase?

islower() − Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.

How will you check in a string that all characters are numerics?

isnumeric() − Returns true if a unicode string contains only numeric characters and false otherwise.

How will you check in a string that all characters are whitespaces?

isspace() − Returns true if string contains only whitespace characters and false otherwise.

Why is Finally Block used in Python Exception Handling?

A Finally Block is generally used in association with try and catch blocks in Python. A Finally Block executes itself no matter if an error occurs at run time or not. It is the default execution block in Python Exception Handling technique.

How is the memory management process in Python?

Like other programming environments, Python Programming Environment has Garbage Collection Techniques that manages the Memory efficiently. Moreover, the memory is managed by the Private Heap which is ultimately managed by the Python Memory Manager.

How do you include comment feature in a Python program?

Python Programming Environment supports good features for comment as it helps the developers to document the code without any confusion. You can write a comment in a Python program using the following command:

Syntax:
# Comment Here

What is the difference between input() method and raw_input() method?

raw_input() method returns string values whereas input() method returns integer vaues.
Input() method was used in Python 2.x versions whereas Python 3.x and later versions use raw_input() method. However, input()method has been replaced by raw_input() method in Python 3.x.

What is the difference between Lists and Tuples in terms of Syntax?

Both Lists and Tuples are used to store a sequence of data within them. However, a major difference between them is that Tuples use parantheses ( ) in its syntax whereas Lists use Brackets in its syntax [ ].

What is the difference between Text Entry element and Text Box element in Tkinter Module?

A Text Entry element is used to receive an input of only one single line whereas a Text Box provides a space to receive input for multiple lines.

How do you create a Check Button Element in Python?

The CheckButton class is available in Tkinter Module. We first need to import it and then we can take in a frame label by the following command:

checkbutton1 = Checkbutton(frame1, text= “C Programming”)
checkbutton1.grid()

checkbutton1 is a variable to hold the Check Button Element and frame1 is the name of the Frame variable onto which we want to adjust our Check Button. It takes in a parameter named as Text which is used to display the name for the Check Button.

Enlist the built in datatypes that Python provides.

The datatypes provides by Python are as follows:
1. List
2. Tuple
3. Dictionary
4. String
5. Number
6. Set

What is a DocString and what is it used for?

A DocString represents Document String that is used to Document Python Modules, Classes and Methods.

How do you define the dimensions of a window in a Python Graphics Program?

We can define the dimensions i.e., width and height of a Window in a Python GUI programming. It can be defined using the geometry() method. It takes in two parameters: width and height respectively.

Example: geometry(“width * height”).

Subscribe to get more Posts :