October 12, 2018

Sreekanth B

Globant Most Frequently Asked Python Latest Interview Questions Answers

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

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

How will you check in a string that it is properly titlecased?

istitle() − Returns true if string is properly “titlecased” and false otherwise.

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

isupper() − Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.

How will you merge elements in a sequence?

join(seq) − Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.

How will you get the length of the string?

len(string) − Returns the length of the string.

How will you get a space-padded string with the original string left-justified to a total of width columns?

just(width[, fillchar]) − Returns a space-padded string with the original string left-justified to a total of width columns.
Globant Most Frequently Asked Python Latest Interview Questions Answers
Globant Most Frequently Asked Python Latest Interview Questions Answers

How will you convert a string to all lowercase?

lower() − Converts all uppercase letters in string to lowercase.

How will you remove all leading whitespace in string?

strip() − Removes all leading whitespace in string.

How will you get the max alphabetical character from the string?

max(str) − Returns the max alphabetical character from the string str.

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”)

Enlist the Looping constructs available in Python.

Python provides using two looping constructs and these are For Loop and While Loop. Both of these looping constructs are same. The only difference is of the syntax that both of these use.

What is range() method in Python?

Range() method is Python is used as a Looping construct. It takes in 2 mandatory parameters and 1 optional parameter.

Example: range(1,10,2)

This method prints numbers after every alternate iterations between 1 and 10. It prints 1 3 5 7 9.

Are indentations mandatory to use in Python?

Indentations are very much important to use in Python. We normally do not use braces to indicate the scope of a function in a Python program. Indentation lets the Python Interpreter to understand the scope of a function automatically. Not using indentations properly in a Python program generates errors normally.

Subscribe to get more Posts :