Asus Most Frequently Asked Python Latest Interview Questions Answers
What is the output of L[2] if L = [1,2,3]?
3, Offsets start at zero.
What is the output of L[-2] if L = [1,2,3]?
L[-1] = 3, L[-2]=2, L[-3]=1
What is the output of L[1:] if L = [1,2,3]?
2, 3, Slicing fetches sections.
How will you compare two lists?
cmp(list1, list2) − Compares elements of both lists.
How will you get the length of a list?
len(list) − Gives the total length of the list.
How will you get the max valued item of a list?
max(list) − Returns item from the list with max value.
How will you get the min valued item of a list?
min(list) − Returns item from the list with min value.
How will you get the index of an object in a list?
list.index(obj) − Returns the lowest index in list that obj appears.
How will you insert an object at given index in a list?
list.insert(index, obj) − Inserts object obj into list at offset index.
How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
How will you remove an object from a list?
list.remove(obj) − Removes object obj from list.
How will you reverse a list?
list.reverse() − Reverses objects of list in place.
What is the output of L[2] if L = [1,2,3]?
3, Offsets start at zero.
What is the output of L[-2] if L = [1,2,3]?
L[-1] = 3, L[-2]=2, L[-3]=1
What is the output of L[1:] if L = [1,2,3]?
2, 3, Slicing fetches sections.
How will you compare two lists?
cmp(list1, list2) − Compares elements of both lists.
How will you get the length of a list?
len(list) − Gives the total length of the list.
How will you get the max valued item of a list?
max(list) − Returns item from the list with max value.
How will you get the min valued item of a list?
min(list) − Returns item from the list with min value.
Asus Most Frequently Asked Python Latest Interview Questions Answers |
How will you get the index of an object in a list?
list.index(obj) − Returns the lowest index in list that obj appears.
How will you insert an object at given index in a list?
list.insert(index, obj) − Inserts object obj into list at offset index.
How will you remove last object from a list?
list.pop(obj=list[-1]) − Removes and returns last object or obj from list.
How will you remove an object from a list?
list.remove(obj) − Removes object obj from list.
How will you reverse a list?
list.reverse() − Reverses objects of list in place.
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.
What is a Frame in Python GUI?
A Frame in Python can be related as a storage holder for other Graphical User Interface or GUI elements such as Label, Text Entry, Text Box, Check Button, Radio Button, etc.
What is another method for Using Loops with While Loop and For Loop?
Python provides a method named as range() that provides looping constructs. It works in similar fashion as while and for loop. It takes in 2 compulsory parameters and 1 optional parameter.
What is namespace in Python?
For every variable that is introduced in Python, there is a namespace that is associated with the place holder for that particular variable. It is a place holder where a variable can be linked to the object placed.
Does Python Compiled Code contains Byte-Codes?
No. Python is primarily an Interpreted Language. However, at first the .py file is compiled to something called as Python Byte-Code which is not a file that contains Binary digits like other Programming environments. It actually contains Python specific instructions that helps in optimizing the startup speed.
Does Python Supports Switch Case statements?
No, Python does not have provision for Switch Case statements. However, it provides with an alternative called as ‘One-to-One Mapping’.
How do you create a Button Element in Python?
The Button 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:
button1 = Button(frame1, text = “I am a Button”)
button1.grid()
button 1 is a variable to hold the Button Element and frame 1 is the name of the Frame variable onto to which we want to adjust our Button. It is mandatory to define the Frame first.
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.
What is a Frame in Python GUI?
A Frame in Python can be related as a storage holder for other Graphical User Interface or GUI elements such as Label, Text Entry, Text Box, Check Button, Radio Button, etc.
What is another method for Using Loops with While Loop and For Loop?
Python provides a method named as range() that provides looping constructs. It works in similar fashion as while and for loop. It takes in 2 compulsory parameters and 1 optional parameter.
What is namespace in Python?
For every variable that is introduced in Python, there is a namespace that is associated with the place holder for that particular variable. It is a place holder where a variable can be linked to the object placed.
Does Python Compiled Code contains Byte-Codes?
No. Python is primarily an Interpreted Language. However, at first the .py file is compiled to something called as Python Byte-Code which is not a file that contains Binary digits like other Programming environments. It actually contains Python specific instructions that helps in optimizing the startup speed.
Does Python Supports Switch Case statements?
No, Python does not have provision for Switch Case statements. However, it provides with an alternative called as ‘One-to-One Mapping’.
How do you create a Button Element in Python?
The Button 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:
button1 = Button(frame1, text = “I am a Button”)
button1.grid()
button 1 is a variable to hold the Button Element and frame 1 is the name of the Frame variable onto to which we want to adjust our Button. It is mandatory to define the Frame first.
Post a Comment