Amazon Python Recent Asked Interview Questions Answers

How to take input from the User in Python?

Python provides a built-in method to accept input from the user.
It is as follows: input(“Enter the Input”)
However, in order to store the input in a variable, you must write a variable name before the input() method.
It can done as follows: var1=input(“Enter the input”)

Is Python a Scripting Language or not?

Python is a General-Purpose Programming Language or rather a Multi-Purpose Programming Language. It is also a Scripting Language as it can be used to combine it into HTML Code used for Web Development.

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.
Amazon Python Recent Asked Interview Questions Answers
Amazon Python Recent Asked Interview Questions Answers
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.

How will you convert a string to a list in python?

list(s) − Converts s to a list.

How will you convert a string to a set in python?

set(s) − Converts s to a set.

How will you create a dictionary using tuples in python?

dict(d) − Creates a dictionary. d must be a sequence of (key,value) tuples.

How will you convert a string to a frozen set in python?

frozenset(s) − Converts s to a frozen set.


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.

How will you sort a list?

list.sort([func]) − Sorts objects of list, use compare func if given.

Q97).Name five modules that are included in python by default (many people come searching for this, so I included some more examples of modules which are often used)

datetime           (used to manipulate date and time)
re                         (regular expressions)
urllib, urllib2  (handles many HTTP things)
string                  (a collection of different groups of strings for example all lower_case letters etc)
itertools            (permutations, combinations and other useful iterables)
ctypes                (from python docs: create and manipulate C data types in Python)
email                  (from python docs: A package for parsing, handling, and generating email messages)
__future__      (Record of incompatible language changes. like division operator is different and much better when imported from __future__)
sqlite3               (handles database of SQLite type)
unittest             (from python docs: Python unit testing framework, based on Erich Gamma’s JUnit and Kent Beck’s Smalltalk testing framework)
xml                     (xml support)
logging              (defines logger classes. enables python to log details on severity level basis)
os                        (operating system support)
pickle                (similar to json. can put any data structure to external files)
subprocess    (from docs: This module allows you to spawn processes, connect to their input/output/error pipes, and obtain their return codes)
webbrowser  (from docs: Interfaces for launching and remotely controlling Web browsers.)
traceback       (Extract, format and print Python stack traces)

Name a module that is not included in python by default

mechanize

django
gtk
A lot of other can be found at pypi.


Post a Comment

Previous Post Next Post