PWP QUESTION BANK
1. Compare global and local variable
2. Enlist the basic set of operator with eg
A. Union set
Union operation perform on two sets returns all the
elements from both the sets
It is performed by using | operator
B. Intersection set
Intersection operation performed on two sets returns all
the elements which are common or in both the sets
It is performed by using & operator
C. Difference set
Difference operations performed on two sets , set1 and
set2 returns all the elements which are present on set 1
but not in set 2
it is performed by using - operator
D. Symmetric Difference
Symmetric difference operation performed by using
^ operations . The symmetric difference of two sets A
and B is the set (A-B) symbol (B-A) it represents set of all
elements which belong either to A or B but not both
3. Explain any 4 built in function in dictionary
4. What is type casting or type conversion
Python defined type conversion functions to directly
convert one data type to another data type is known as
type conversion or type casting
In python type conversion can happen in the following
two ways
1.Python implicit data type conversion
2.Python explicit data type conversion
5. What is user-defined functions
6. Explain any 4 math module with eg
7. What is module ,enlist python built-in module , explain
any 2
Modules: Python modules are files that contain Python
code and can be imported into other Python programs
to reuse code and simplify development.
8. Enlist the standard packages in python , explain any 2
1.NumPy
2.SciPy
9. Define
Class
classes are defined by the user. The class provide the
basic structure for an object .It consists of data members
and method members that are used by the instances,
(objects) of the class.
Object
A unique instance of a data structure that is defined by
its class an object comprises both data members (class
variable and instance variables) and methods
Inheritance
The transfer of the characteristics of a class to other
class that are derived from it it’s called inheritance
a Class A that can use a characteristics of another class B
is Said to be a derived class i.e a class inherited from B
this process is called inheritance
Polymorphism
Polymorphism allows one interface to be huge for a set
of action that is one name may refer to different
functionality the word polymorphism means having
many forms
In programming polymorphism means same function
name being usage for different types
Data Hiding
Data hiding is a concept which underlines the hiding of
data or information from the user.
Data hiding is a software development technique
specifically used in Object-Oriented Programming (OOP)
to hide internal object details (data members).
Data Encapsulation
Encapsulation is a process of binding together the
methods and data variables as a single entity i.e , class
this keep both the data and functionality of the core say
from the outside world
Data Abstraction
The basic idea of data abstraction is to visible only the
necessary information
unnecessary information will be hidden from the outside
world
Abstraction is the process of hiding the implementation
details and showing only functionality to the user
10. What are access modifier explain with methods
11. Method overloading vs method overriding
12. What is inheritance list types with syntax
• Single
• Multiple
• Multilevel
• Hierarchical
• Hybrid
In inheritance objects of one class procure the
properties of objects of another class. Inheritance
provide code usability, which means that some of
the new features can be added to the code while
using the existing code. The mechanism of
designing or constructing classes from other classes
is called inheritance.
Syntax:
class A:
# properties of class A
class B(A):
# class B inheriting property of class A
# more properties of class B
13. What is file which are 2 categories of file & what
are the operations used in python In file
File is a name location on this to store related
information it is used to permanently store data in a
non-volatile memory i.e hard disk
while files divided into two categories
1.Text file – text files are simple texts in human readable
format
2.Binary files – binary files have binary data which us
understood by computer
Following are the operations of the files
• Opening file (using open() function)
• Reading file (using read() function)
• Writing file (using write() function)
• Copy files
• Delete files (using remove() function)
• Closing file (Using close() function)
14. Describe the funtions of
Seek()
Tell ()
Writelines(list)method
Readlines()
seek():
In python programming, within file handling concept seek()
function is used to shift/change the position of file object to
required position
Syntax :f.seek(offset, fromwhere)
tell():
tell() returns the current position of the file pointer from the
beginning of the file.
Syntax: file.tell()
readline([n]) Method:
The readline() method just output the entire line whereas
readline(n) outputs at most n bytes of a single line of a file. It
does not read more than one line. Once, the end of file is
reached, we get empty string on further reading.