SlideShare a Scribd company logo
1 of 5
Python Interview Questions
A list of top frequently asked Python interview questions
and answers are given below.
1) What is Python?
Python is a high level object-oriented programming language
with objects, modules, threads, exceptions and automatic
memory management. It is a simple yet powerful
programming language. It can run equally on different
platforms such as Windows, Linux, UNIX, Macintosh etc. Thus,
Python is a portable language.
2) What are the advantages of Python?
Following are the main advantages of using Python.
◦ Free and open source
◦ Portable
◦ Extensible
◦ Object oriented
◦ Built-in data structure
3)What is PEP 8?
PEP 8 is a coding convention which specifies a set of
guidelines, about how to write your Python code more
readable.
4)What is used to create Unicode string in
Python?
You should use "Unicode" before the string. For example:
Unicode (text).
5) Explain how Python is interpreted?
Python is an interpreted language. The Python language
program runs directly from the source code. It converts the
source code into an intermediate language, which is again
translated into machine language that has to be executed.
6) How memory is managed in Python?
Memory is managed in Python in following way:
◦ Memory is managed in Python by private heap space. All
Python objects and data structures are located in a
private heap. The programmer does not have an access
to this private heap and interpreter takes care of this
Python private heap.
◦ Python memory manager is responsible for allocating Python
heap space for Python objects.
◦ Python also have an inbuilt garbage collector, which recycle
all the unused memory and frees the memory and makes
it available to the heap space.
7) What is Python decorator?
A Python decorator is a specific change made within Python
syntax to alter functions easily.
8)What are the rules for local and global
variable inPython?
In Python, variables that are only referenced inside a function
are called implicitly global. If a variable is assigned a new
value anywhere within the function's body, it's assumed to be
a local. If a variable is ever assigned a new value inside the
function, the variable is implicitly local, and you need to
explicitly declare it as 'global'.
9) What is namespace in Python?
In Python, every name has a place where it lives and can be
hooked for. This is known as namespace. It is like a box where
a variable name is mapped to the object placed. Whenever the
variable is searched out, this box will be searched, to get
corresponding object.
10) What are iterators in Python?
In Python, iterators are used to iterate a group of elements,
containers like list.
11) What is generator in Python?
In Python, generator is a way that specifies how to implement
iterators. It is a normal function except that it yields
expression in thefunction.
12) What is slicing in Python?
Slicing is a mechanism used to select a range of items from
sequence type like list, tuple, string etc.
13) What is dictionary in Python?
The built-in datatypes in Python is called dictionary. It defines
one-to-one relationship between keys and values. Dictionaries
contain pair of keys and their corresponding values.
Dictionaries are indexed by keys.
Let's take an example
The following example contains some keys ? Country Hero &
Cartoon. Their corresponding values are India, Modi and Rahul
respectively.
1 >>> dict = {'Country': 'India', 'Hero': 'Modi', 'Cartoon': 'Rah
ul'}
2 >>>print dict[Country]
3 India
4 >>>print dict[Hero]
5 Modi
6 >>>print dict[Cartoon]
7 Rahul
14) What is Pass in Python?
Pass specifies a Python statement without operations. It is a
place holder in a compound statement, where there should be
a blank left and nothing has to be written there.
15) Explain docstring in Python?
A Python documentation string is called docstring. It is used
for documenting Python functions, modules and classes.
16) What is negative index in Python?
Python sequences are indexed in positive and negative
numbers. For example: 0 is the first positive index, 1 is the
second positive index and so on. For negative indexes -1 is the
last negative index, -2 is the second last negative index and so
on.
17)What is pickling and unpickling in
Python?
Pickling is a process in which a pickle module accepts any
Python object, converts it into a string representation and
dumps it into a file by using dump() function.
Unpickling is a process of retrieving original Python object
from the stored string representation for use.
Pickle is a standard modulewhich serializes and de-serializes
a Python objectstructure.
18) How can you make forms in Python?
You have to import cgi module to access form fields using
FieldStorage class.
Attributes of class FieldStorage for form:
form.name: The name of the field, if specified.
form.filename: If an FTP transaction, the client-side
filename.
form.value: The value of the field as a string.
form.file: file object from which data can be read.
form.type: The content type, if applicable.
form.type_options: The options of the 'content-type' line of
the HTTP request, returned as a dictionary.
form.disposition: The field 'content-disposition'; None, if
unspecified.
form.disposition_options: The options for 'content-
disposition'.
form.headers: All of the HTTP headers returned as a
dictionary.
Example
1 import cgi
2 form = cgi.FieldStorage()
3if not (form.has_key("name") and form.has_key("age")):
4 print "<H1>Name & Age not Entered</H1>"
5 print "Fill the Name & Age accurately."
6 return
7 print "<p>name:", form["name"].value
8 print "<p>Age:", form["age"].value
19)What are the differences between
Python 2.x and Python 3.x?
Python 2.x is an older version of Python. It is a legacy now.
Python 3.x is newer. It is the present and future of this
language.
The most visible difference between them is in print
statement. In Python 2 it is print ?Hello? and in Python 3, it is
print (?Hello?).
20)How can you organize your code to
make it easier to change the base class?
You have to define an alias for the base class, assign the real
base class to it before your class definition, and use the alias
throughout your class. you can also use this method if you
want to decide dynamically (e.g. depending on availability of
resources) which base class to use.
Example
1 BaseAlias = <real base class>
2 class Derived(BaseAlias):
3 def meth(self):
4 BaseAlias.meth(self)

More Related Content

What's hot

What's hot (20)

Programming
ProgrammingProgramming
Programming
 
Python for kids - 1.pptx
Python for kids - 1.pptxPython for kids - 1.pptx
Python for kids - 1.pptx
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
C++ Chapter 3
C++ Chapter 3C++ Chapter 3
C++ Chapter 3
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Vi editor
Vi editorVi editor
Vi editor
 
Procedural vs. object oriented programming
Procedural vs. object oriented programmingProcedural vs. object oriented programming
Procedural vs. object oriented programming
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
Python
PythonPython
Python
 
Requêtes HTTP synchrones et asynchrones
Requêtes HTTPsynchrones et asynchronesRequêtes HTTPsynchrones et asynchrones
Requêtes HTTP synchrones et asynchrones
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Python
PythonPython
Python
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
HCI LAB MANUAL
HCI LAB MANUAL HCI LAB MANUAL
HCI LAB MANUAL
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variables
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 

Similar to Python interview questions and answers

Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 

Similar to Python interview questions and answers (20)

Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python_Unit_1.pdf
Python_Unit_1.pdfPython_Unit_1.pdf
Python_Unit_1.pdf
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Python unit1
Python unit1Python unit1
Python unit1
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
Python intro
Python introPython intro
Python intro
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
Intro to python
Intro to pythonIntro to python
Intro to python
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdf
 
Python presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharPython presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, Bihar
 
Core python programming tutorial
Core python programming tutorialCore python programming tutorial
Core python programming tutorial
 
GE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_NotesGE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_Notes
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
prakash ppt (2).pdf
prakash ppt (2).pdfprakash ppt (2).pdf
prakash ppt (2).pdf
 

Recently uploaded

在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
qh1ao5mm
 
John Deere 990 Compact Utility Tractor Shop Manual.pdf
John Deere 990 Compact Utility Tractor Shop Manual.pdfJohn Deere 990 Compact Utility Tractor Shop Manual.pdf
John Deere 990 Compact Utility Tractor Shop Manual.pdf
Excavator
 
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
AS
 
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
A
 
mechanical vibrations pebbles.pptbbbbbbbbx
mechanical vibrations pebbles.pptbbbbbbbbxmechanical vibrations pebbles.pptbbbbbbbbx
mechanical vibrations pebbles.pptbbbbbbbbx
joshuaclack73
 
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
62qaf0hi
 
出售伯明翰大学毕业证研究生文凭证书原版质量
出售伯明翰大学毕业证研究生文凭证书原版质量出售伯明翰大学毕业证研究生文凭证书原版质量
出售伯明翰大学毕业证研究生文凭证书原版质量
kthcah
 
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
huxs9sacp
 
industry 4.0-Revolution-PowerPoint-Templates (1).pptx
industry 4.0-Revolution-PowerPoint-Templates (1).pptxindustry 4.0-Revolution-PowerPoint-Templates (1).pptx
industry 4.0-Revolution-PowerPoint-Templates (1).pptx
longswitchmeeting
 
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
kthcah
 
uipath-interview-questions.pdf it was productive
uipath-interview-questions.pdf it was productiveuipath-interview-questions.pdf it was productive
uipath-interview-questions.pdf it was productive
sfvfmbgpq2
 
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
eehzz
 
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
wsppdmt
 

Recently uploaded (20)

在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
 
EV Charging Resources and Technical Assistance for Rural Communities and Trib...
EV Charging Resources and Technical Assistance for Rural Communities and Trib...EV Charging Resources and Technical Assistance for Rural Communities and Trib...
EV Charging Resources and Technical Assistance for Rural Communities and Trib...
 
John Deere 990 Compact Utility Tractor Shop Manual.pdf
John Deere 990 Compact Utility Tractor Shop Manual.pdfJohn Deere 990 Compact Utility Tractor Shop Manual.pdf
John Deere 990 Compact Utility Tractor Shop Manual.pdf
 
Effortless Driving Experience Premier Mercedes Sprinter Suspension Service
Effortless Driving Experience Premier Mercedes Sprinter Suspension ServiceEffortless Driving Experience Premier Mercedes Sprinter Suspension Service
Effortless Driving Experience Premier Mercedes Sprinter Suspension Service
 
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
一比一原版(Auburn毕业证书)奥本大学毕业证原件一模一样
 
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
一比一原版(Rutgers毕业证书)罗格斯大学毕业证成绩单原件一模一样
 
mechanical vibrations pebbles.pptbbbbbbbbx
mechanical vibrations pebbles.pptbbbbbbbbxmechanical vibrations pebbles.pptbbbbbbbbx
mechanical vibrations pebbles.pptbbbbbbbbx
 
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
一比一原版(Deakin毕业证书)迪肯大学毕业证成绩单留信学历认证
 
Things that make the new Nissan Z unique
Things that make the new Nissan Z uniqueThings that make the new Nissan Z unique
Things that make the new Nissan Z unique
 
出售伯明翰大学毕业证研究生文凭证书原版质量
出售伯明翰大学毕业证研究生文凭证书原版质量出售伯明翰大学毕业证研究生文凭证书原版质量
出售伯明翰大学毕业证研究生文凭证书原版质量
 
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
如何办理(爱大毕业证书)爱丁堡大学毕业证成绩单留信学历认证真实可查
 
industry 4.0-Revolution-PowerPoint-Templates (1).pptx
industry 4.0-Revolution-PowerPoint-Templates (1).pptxindustry 4.0-Revolution-PowerPoint-Templates (1).pptx
industry 4.0-Revolution-PowerPoint-Templates (1).pptx
 
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
快速办理澳洲昆士兰科技大学毕业证教育部学历认证书一模一样
 
Access to Rural Charging by David Skakel
Access to Rural Charging by David SkakelAccess to Rural Charging by David Skakel
Access to Rural Charging by David Skakel
 
Auto Glass Repair in Redwood City What to Do When Disaster Strikes.pdf
Auto Glass Repair in Redwood City What to Do When Disaster Strikes.pdfAuto Glass Repair in Redwood City What to Do When Disaster Strikes.pdf
Auto Glass Repair in Redwood City What to Do When Disaster Strikes.pdf
 
Why Is The Glow Plug Light Flashing In My VW & What Does It Indicate
Why Is The Glow Plug Light Flashing In My VW & What Does It IndicateWhy Is The Glow Plug Light Flashing In My VW & What Does It Indicate
Why Is The Glow Plug Light Flashing In My VW & What Does It Indicate
 
uipath-interview-questions.pdf it was productive
uipath-interview-questions.pdf it was productiveuipath-interview-questions.pdf it was productive
uipath-interview-questions.pdf it was productive
 
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
原版定做(ncl学位证书)英国纽卡斯尔大学毕业证文凭学历证书-国外学历学位认证
 
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
 
How Do I Know If My Volvo Has Throttle Position Sensor Problems
How Do I Know If My Volvo Has Throttle Position Sensor ProblemsHow Do I Know If My Volvo Has Throttle Position Sensor Problems
How Do I Know If My Volvo Has Throttle Position Sensor Problems
 

Python interview questions and answers

  • 1. Python Interview Questions A list of top frequently asked Python interview questions and answers are given below. 1) What is Python? Python is a high level object-oriented programming language with objects, modules, threads, exceptions and automatic memory management. It is a simple yet powerful programming language. It can run equally on different platforms such as Windows, Linux, UNIX, Macintosh etc. Thus, Python is a portable language. 2) What are the advantages of Python? Following are the main advantages of using Python. ◦ Free and open source ◦ Portable ◦ Extensible ◦ Object oriented ◦ Built-in data structure 3)What is PEP 8? PEP 8 is a coding convention which specifies a set of guidelines, about how to write your Python code more readable. 4)What is used to create Unicode string in Python? You should use "Unicode" before the string. For example: Unicode (text). 5) Explain how Python is interpreted? Python is an interpreted language. The Python language program runs directly from the source code. It converts the source code into an intermediate language, which is again translated into machine language that has to be executed. 6) How memory is managed in Python? Memory is managed in Python in following way: ◦ Memory is managed in Python by private heap space. All
  • 2. Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap. ◦ Python memory manager is responsible for allocating Python heap space for Python objects. ◦ Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space. 7) What is Python decorator? A Python decorator is a specific change made within Python syntax to alter functions easily. 8)What are the rules for local and global variable inPython? In Python, variables that are only referenced inside a function are called implicitly global. If a variable is assigned a new value anywhere within the function's body, it's assumed to be a local. If a variable is ever assigned a new value inside the function, the variable is implicitly local, and you need to explicitly declare it as 'global'. 9) What is namespace in Python? In Python, every name has a place where it lives and can be hooked for. This is known as namespace. It is like a box where a variable name is mapped to the object placed. Whenever the variable is searched out, this box will be searched, to get corresponding object. 10) What are iterators in Python? In Python, iterators are used to iterate a group of elements, containers like list. 11) What is generator in Python? In Python, generator is a way that specifies how to implement iterators. It is a normal function except that it yields expression in thefunction. 12) What is slicing in Python?
  • 3. Slicing is a mechanism used to select a range of items from sequence type like list, tuple, string etc. 13) What is dictionary in Python? The built-in datatypes in Python is called dictionary. It defines one-to-one relationship between keys and values. Dictionaries contain pair of keys and their corresponding values. Dictionaries are indexed by keys. Let's take an example The following example contains some keys ? Country Hero & Cartoon. Their corresponding values are India, Modi and Rahul respectively. 1 >>> dict = {'Country': 'India', 'Hero': 'Modi', 'Cartoon': 'Rah ul'} 2 >>>print dict[Country] 3 India 4 >>>print dict[Hero] 5 Modi 6 >>>print dict[Cartoon] 7 Rahul 14) What is Pass in Python? Pass specifies a Python statement without operations. It is a place holder in a compound statement, where there should be a blank left and nothing has to be written there. 15) Explain docstring in Python? A Python documentation string is called docstring. It is used for documenting Python functions, modules and classes. 16) What is negative index in Python? Python sequences are indexed in positive and negative numbers. For example: 0 is the first positive index, 1 is the second positive index and so on. For negative indexes -1 is the last negative index, -2 is the second last negative index and so on. 17)What is pickling and unpickling in Python? Pickling is a process in which a pickle module accepts any
  • 4. Python object, converts it into a string representation and dumps it into a file by using dump() function. Unpickling is a process of retrieving original Python object from the stored string representation for use. Pickle is a standard modulewhich serializes and de-serializes a Python objectstructure. 18) How can you make forms in Python? You have to import cgi module to access form fields using FieldStorage class. Attributes of class FieldStorage for form: form.name: The name of the field, if specified. form.filename: If an FTP transaction, the client-side filename. form.value: The value of the field as a string. form.file: file object from which data can be read. form.type: The content type, if applicable. form.type_options: The options of the 'content-type' line of the HTTP request, returned as a dictionary. form.disposition: The field 'content-disposition'; None, if unspecified. form.disposition_options: The options for 'content- disposition'. form.headers: All of the HTTP headers returned as a dictionary. Example 1 import cgi 2 form = cgi.FieldStorage() 3if not (form.has_key("name") and form.has_key("age")): 4 print "<H1>Name & Age not Entered</H1>" 5 print "Fill the Name & Age accurately." 6 return 7 print "<p>name:", form["name"].value 8 print "<p>Age:", form["age"].value 19)What are the differences between Python 2.x and Python 3.x? Python 2.x is an older version of Python. It is a legacy now. Python 3.x is newer. It is the present and future of this language. The most visible difference between them is in print statement. In Python 2 it is print ?Hello? and in Python 3, it is
  • 5. print (?Hello?). 20)How can you organize your code to make it easier to change the base class? You have to define an alias for the base class, assign the real base class to it before your class definition, and use the alias throughout your class. you can also use this method if you want to decide dynamically (e.g. depending on availability of resources) which base class to use. Example 1 BaseAlias = <real base class> 2 class Derived(BaseAlias): 3 def meth(self): 4 BaseAlias.meth(self)