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.
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.
How will you get the min alphabetical character from the string?
min(str) − Returns the min alphabetical character from the string str.
How will you replaces all occurrences of old substring in string with new string?
replace(old, new [, max]) − Replaces all occurrences of old in string with new or at most max occurrences if max given.
How will you remove all leading and trailing whitespace in string?
strip([chars]) − Performs both lstrip() and rstrip() on string.
How will you change case for all letters in string?
swapcase() − Inverts case for all letters in string.
How will you get titlecased version of string?
title() − Returns “titlecased” version of string, that is, all words begin with uppercase and the rest are lowercase.
How will you convert a string to all uppercase?
upper() − Converts all lowercase letters in string to uppercase.
How will you check in a string that all characters are decimal?
isdecimal() − Returns true if a unicode string contains only decimal characters and false otherwise.
What is the difference between del() and remove() methods of list?
To remove a list element, you can use either the del statement if you know exactly which element(s) you are deleting or the remove() method if you do not know.
What is the output of len([1, 2, 3])?
3.
What is the output of [1, 2, 3] + [4, 5, 6]?
[1, 2, 3, 4, 5, 6]
What is the output of [‘Hi!’] * 4?
[‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’]
What is the output of 3 in [1, 2, 3]?
True
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.
Which method is used to find out the location of the pointer in a file?
The tell() method is used to return the current location or position of the read/write pointer within the file. This method doesn’t require any parameter to be passed in it.
Syntax:
FileVariableName.tell()
Enlist the Mutable Built-in types in Python programming environment?
The Mutable Built-in types in Python Programming Environment are as follows:
1. Sets
2. Dictionaries
3. Lists
How do you create a Text Box Element in Python?
The Text Box 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:
text1 = Text(frame1, width = 35, height = 5)
text1.grid()
text1 is a variable to hold the Text Element and frame1 is the the name of the Frame variable onto to which we want to adjust our Text Box. It has two parameters viz., width and height that defines its dimensions.
It is mandatory to define the Frame first.
Enlist some of GUI Elements in Python Tkinter module?
Frame, Label, Text Entry, Check Button, Radio Button, Text Box are some of the few Tkinter GUI Elements used in Python.
Which method is used to set the file pointer at a particular location?
The seek() method is used to set the File pointer to a particular position in the Text File. It takes in two parameters out of which the first one is mandatory and the second one is optional.
Syntax:
seek(location, source)
What is Tkinter in Python and what is it used for?
Tkinter is a Python module available for Python programmers for development of Graphical User Interface (GUI) programs. Tkinter module is used to import the methods required for creation of GUI in a Python program.
How are exceptions handled in Python?
An Exception is raised by Python when an error occurs at program run-time. Python Exceptions can be caught using try and catch blocks. When you are suspicious of a statement, move it it into the try block and on error the control moves into the catch block and a pre-defined activity can be executed which helps to avoid an abnormal termination of the program.
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.
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.
How will you get the min alphabetical character from the string?
min(str) − Returns the min alphabetical character from the string str.
Sitel Most Frequently Asked Python Latest Interview Questions Answers |
How will you replaces all occurrences of old substring in string with new string?
replace(old, new [, max]) − Replaces all occurrences of old in string with new or at most max occurrences if max given.
How will you remove all leading and trailing whitespace in string?
strip([chars]) − Performs both lstrip() and rstrip() on string.
How will you change case for all letters in string?
swapcase() − Inverts case for all letters in string.
How will you get titlecased version of string?
title() − Returns “titlecased” version of string, that is, all words begin with uppercase and the rest are lowercase.
How will you convert a string to all uppercase?
upper() − Converts all lowercase letters in string to uppercase.
How will you check in a string that all characters are decimal?
isdecimal() − Returns true if a unicode string contains only decimal characters and false otherwise.
What is the difference between del() and remove() methods of list?
To remove a list element, you can use either the del statement if you know exactly which element(s) you are deleting or the remove() method if you do not know.
What is the output of len([1, 2, 3])?
3.
What is the output of [1, 2, 3] + [4, 5, 6]?
[1, 2, 3, 4, 5, 6]
What is the output of [‘Hi!’] * 4?
[‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’]
What is the output of 3 in [1, 2, 3]?
True
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.
Which method is used to find out the location of the pointer in a file?
The tell() method is used to return the current location or position of the read/write pointer within the file. This method doesn’t require any parameter to be passed in it.
Syntax:
FileVariableName.tell()
Enlist the Mutable Built-in types in Python programming environment?
The Mutable Built-in types in Python Programming Environment are as follows:
1. Sets
2. Dictionaries
3. Lists
How do you create a Text Box Element in Python?
The Text Box 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:
text1 = Text(frame1, width = 35, height = 5)
text1.grid()
text1 is a variable to hold the Text Element and frame1 is the the name of the Frame variable onto to which we want to adjust our Text Box. It has two parameters viz., width and height that defines its dimensions.
It is mandatory to define the Frame first.
Enlist some of GUI Elements in Python Tkinter module?
Frame, Label, Text Entry, Check Button, Radio Button, Text Box are some of the few Tkinter GUI Elements used in Python.
Which method is used to set the file pointer at a particular location?
The seek() method is used to set the File pointer to a particular position in the Text File. It takes in two parameters out of which the first one is mandatory and the second one is optional.
Syntax:
seek(location, source)
What is Tkinter in Python and what is it used for?
Tkinter is a Python module available for Python programmers for development of Graphical User Interface (GUI) programs. Tkinter module is used to import the methods required for creation of GUI in a Python program.
How are exceptions handled in Python?
An Exception is raised by Python when an error occurs at program run-time. Python Exceptions can be caught using try and catch blocks. When you are suspicious of a statement, move it it into the try block and on error the control moves into the catch block and a pre-defined activity can be executed which helps to avoid an abnormal termination of the program.
Post a Comment