PDS Question Bank Unit 1 and 2
PDS Question Bank Unit 1 and 2
PART- A (2 Marks)
1. What is meant by interpreter?
An interpreter is a computer program that executes instructions written in a programming language. It can
either execute the source code directly or translate the source code in a first step into a more efficient
representation and executes this code.
2. How will you invoke the python interactive interpreter?
The Python interpreter can be invoked by typing the command "python" without any parameter followed
by the "return" key at the shell prompt.
3. What are the commands that are used to exit from the python interpreter in UNIX and windows?
CTRL+D is used to exit from the python interpreter in UNIX and CTRL+Z is used to exit from the python
interpreter in windows.
4. Define a variable and write down the rules for naming a variable.
A name that refers to a value is a variable. Variable names can be arbitrarily long. They can contain both
letters and numbers, but they have to begin with a letter. It is legal to use uppercase letters, but it is good
tobegin variable names with a lowercase letter.
5. Write a snippet to display “Hello World” in python interpreter.
In script mode:
>>>print("Hello World")Hello World
In Interactive Mode:
>>> "Hello World"'Hello World'
6. List down the basic data types in Python.
Numbers
String
List
Tuple
Dictionary
7. Define keyword and enumerate some of the keywords in Python. (Jan-2019)
A keyword is a reserved word that is used by the compiler to parse a program. Keywords cannot be used
asvariable names. Some of the keywords used in python are:
and
del
from
not
while
is
continue
8. What do you mean by an operand and an operator? Illustrate your answer with relevant example.
An operator is a symbol that specifies an operation to be performed on the operands. The data items that
anoperator acts upon are called operands. The operators +, -, *, / and ** perform addition, subtraction,
multiplication, division and exponentiation.
Example: 20+32.In this example, 20 and 32 are operands and + is an operator.
9. Explain the concept of floor division.
The operation that divides two numbers and chops off the fraction part is known as floor division.
Example:>>> 5//2= 2
10. Define an expression with example.
An expression is a combination of values, variables, and operators. An expression is evaluated using
assignment operator. Example= X + 17
11. Define statement and mention the difference between statement and an expression.
A statement is a unit of code that the Python interpreter can execute. The important difference is that
anexpression has a value but a statement does not have a value.
12. What is meant by rule of precedence? Give the order of precedence.
The set of rules that govern the order in which expressions involving multiple operators and operands are
evaluated is known as rule of precedence. Parentheses have the highest precedence followed by
exponentiation. Multiplication and division have the next highest precedence followed by addition and
subtraction.
13. Illustrate the use of * and + operators in string with example.
The * operator performs repetition on strings and the + operator performs concatenation on strings.
Example:>>> ‘Hello*3’
Output: HelloHelloHello
>>>’Hello+World’
Output: HelloWorld
14. What is function call?
A function is a named sequence of statements that performs a computation. When you define a function,
you specify the name and the sequence of statements. Later, you can “call” the function by name is called
function call.
Example:
sum() //sum is the function name
15. What is a local variable?
A variable defined inside a function. A local variable can only be used inside its function.
Example:
Def ():
s = "Me too." // local variableprint(s)
a = "I hate spam."f()
print (a)
16. Define arguments and parameter.
A value provided to a function when the function is called. This value is assigned to the corresponding
parameter in the function. Inside the function, the arguments are assigned to variables called parameters.
17. What do you mean by flow of execution?
In order to ensure that a function is defined before its first use, you have to know the order in which
statements are executed, which is called the flow of execution.
Execution always begins at the first statement of the program. Statements are executed one at a time,
inorder from top to bottom.
18. What is the use of parentheses?
Parentheses have the highest precedence and can be used to force an expression to evaluate in the order you
want. It also makes an expression easier to read.
Example: 2 + (3*4) * 7
19. What do you mean by an assignment statement?
An assignment statement creates new variables and gives them values:
>>> Message = 'And now for something completely different'
>>> n = 17
This example makes two assignments. The first assigns a string to a new variable named Message; the second
gives the integer 17 to n.
20. What is tuple? (or) What is a tuple? How literals of type tuples are written? Give example (Jan-
2018)
A tuple is a sequence of immutable Python objects. Tuples are sequences, like lists. The differences
between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas
lists use square brackets. Creating a tuple is as simple as putting different comma-separated values. Comma-
separated values between parentheses can also be used.
Example: tup1 = ('physics', 'chemistry', 1997, 2000); tup2= ();
21. Define module.
A module allows to logically organizing the Python code. Grouping related code into a module
makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes
that can bind and reference. A module is a file consisting of Python code. A module can define functions,
classes and variables. A module can also include runnable code.
22. Name the four types of scalar objects Python has. (Jan-2018)
int
float
bool
None
23. List down the different types of operator.
Python language supports the following types of operators:
Arithmetic operator
Relational operator
Assignment operator
Logical operator
Bitwise operator
Membership operator
Identity operator
24. What is a global variable?
Global variables are the one that are defined and declared outside a function and we need to use them inside
a function.
Example: #This function uses global variable sdef f ():
print(s)# Global scope
s = "I love India"f ()
25. Define function.
A function in Python is defined by a def statement. The general syntax looks like this:
def function-name (Parameter list):
statements # the function body
The parameter list consists of zero or more parameters. Parameters are called arguments, if the function is
called. The function body consists of indented statements. The function body gets executed every time the
function is called. Parameter can be mandatory or optional. The optional parameters (zero or more) must
follow the mandatory parameters.
26. What is the purpose of using comment in python program?
Comments indicate information in a program that is meant for other programmers (or anyone reading the
source code) and has no effect on the execution of the program. In Python, we use the hash (#) symbol to
start writing a comment. Example: #This is a comment
27. State the reasons to divide programs into functions. (Jan-2019)
Creating a new function gives the opportunity to name a group of statements, which makes program easier
to read and debug. Functions can make a program smaller by eliminating repetitive code. Dividing a long
program into functions allows to debug the parts one at a time and then assemble them into a working
whole. Well-designed functions are often useful for many programs.
28. Outline the logic to swap the content of two identifiers without using third variable. (May 2019)
a=10b=20
a=a+bb=a-ba=a-b
print (“After Swapping a=”a,” b=”,b)
29. State about Logical operators available in python language with example. (May 2019)
Logical operators are the and, or, not operators.
31. Write a python program to circulate the values of n variables (Nov / Dec 2019)
no_of_terms = int(input("Enter number of values : "))
list1 = []
for val in range(0,no_of_terms,1):
ele = int(input("Enter integer : "))
list1.append(ele)
print("Circulating the elements of list ", list1)
for val in range(0,no_of_terms,1):
ele = list1.pop(0)
list1.append(ele)
print(list1)
PART B (16 MARKS)
1. What is the role of an interpreter? Give a detailed note on python interpreter and interactive mode of
operation. (or) Sketch the structures of interpreter and compiler. Detail the differences between them.
Explain how Python works in interactive mode and script mode with examples. (Jan 2019) [Page No: 2
to 4]
2. Illustrate values and different standard data types with relevant examples. [Page No: 4 to 6]
3. Define variables. List down the rules for naming the variable with example. [Page No: 7]
4. List down the different types of operators and their function with suitable example. [Page No: 10 to 16]
5. What are the two modes of operation in python? Analyze the differences between them.
6. What do you mean by rule of precedence? List out the order of precedence and demonstrate in detail with
example. [Page No: 17 to 18]
7. Elaborate on tuple assignment. [Page No: 10]
8. What is the use of function? Explain the role of function call and function definition with example. (or)
Outline about function definition and call with example. Why are function needed? (May 2019)
9. Describe flow of execution of function with an example.
10. Write a Python program to circulate the values of n variables.
11. Write a python program to swap two variables.
12. Write a python program to check whether a given year is a leap year or not.
13. Write a python program to convert celsius to fahrenheit .(Formula: celsius * 1.8 = fahrenheit –32).
14. a) What is a numeric literal? Give examples. (4) (Jan-2018) [Page No: 5]
b) Appraise the arithmetic operators in Python with an example. (12) (Jan-2018) [Page No: 11 to 12]
15. a) Outline the operator precedence of arithmetic operators in Python. (6) (Jan-2018) [Page No: 17]
b) Write a Python program to exchange the value of two variables. (4) (Jan-2018)
c) Write a Python program using function to find a sum of first ‘N’even numbers and print
the result.(6)(Jan 2018)
16. a) Mention the list of keywords available in Python. Compare it with variable name. (8) (May 2019)
[Page No: 7]
b) What are Statement? How are they constructed from variable and expression in Python. (8) (May 2019)
[Page No: 8 to 9]
17. (a) Write a python program to rotate a list by right n times with and without slicing technique (4 + 4)
(Nov / Dec 2019)
(b) Discuss about keyword arguments and default arguments in python with example. (4 + 4) (Nov / Dec
2019)
18. (a) Write a python program to print the maximum among ‘n’ randomly generate ‘d’ numbers by storing
them in a list (10) (Nov / Dec 2019)
19. (b) Evaluate the following expressions in python (6) (Nov / Dec 2019)
i) 24 // 6 % 3
ii) float(4 + int(2.39) % 2)
iii) 2 ** 2 ** 3
PART- A (2 Marks)
A boolean expression is an expression that is either true or false. The values true and false are called boolean
values. The following examples use the operator “==” which compares two operands and produces True if
Example :>>> 5 == 6
False
True and False are special values that belongs to the type bool; they are not strings:
Bitwise Operator (& (and), | (or) , ^ (binary Xor), ~(binary 1’s complement , << (binary left shift), >>
Identity(is, is not)
The modulus operator works on integers and yields the remainder when the first operand is divided by the
second. In Python, the modulus operator is a percent sign (%). The syntax is the same as for other operators:
Example:
>>> remainder = 7 % 3
for loops are traditionally used when you have a block of code which you want to repeat a fixed number of
times. he Python for statement iterates over the members of a sequence in order, executing the block
each time.
Syntax:
Example:x = 4
print i
Output:0 1 2 3
X! = y # x is not equal to y
6. Explain while loop with example. (or) Explain flow of execution of while loop with Example.(Jan 2019)
The statements inside the while loop is executed only if the condition is evaluated to true.
Syntax:
while condition:
statements
Example:
n = 10
i=1
while i <= n:
sum = sum + i
7. Explain if-statement and if-else statement with example (or) What are conditional and alternative
executions?
If statement:
Syntax: if (condition):
statement
Example:
if x > 0:
The boolean expression after ‘if’ is called the condition. If it is true, then the indented statement gets
If-else:
A second form of if statement is alternative execution, in which there are two possibilities and the condition
determines which one gets executed. The syntax looks like this:
Example:
if x%2 == 0:
else:
If the remainder when x is divided by 2 is 0, then we know that x is even, and the program displays a
message to that effect. If the condition is false, the second set of statements is executed. Since the condition
Sometimes there are more than two possibilities and we need more than two branches. One way to express
Eg:
if x < y:
elif x > y:
else:
elif is an abbreviation of “else if.” Again, exactly one branch will be executed. There is no limit on the
number of elif statements. If there is an else clause, it has to be at the end, but there doesn’t have to be one.
When a break statement is encountered inside a loop, the loop is immediately terminated and the program
Eg:
while True:
line = raw_input('>')
if line == 'done':
break
print line
print'Done!'
10. What is a continue statement?
The continue statement works somewhat like a break statement. Instead of forcing termination, it forces the
next iteration of the loop to take place, skipping any code in between.
Example:
if num%2==0;
continue
11. What is recursion? (or) Define Recursion with an example.(Jan 2019) (May 2019)
The process in which a function calls itself directly or indirectly is called recursion and the corresponding
function is called as recursive function. Using recursive algorithm, certain problems can be solved quite
easily. Examples of such problems are Towers of Hanoi (TOH), Inorder/Preorder/Postorder Tree Traversals,
Example:
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n-1)
12. Compare return value and composition.
Python strings are immutable. ‘a’ is not a string. It is a variable with string value. You can’t mutate the
string but can change what value of the variable to a new string.
Program: Output:
a = “foo” #foofoo
# b now points to the same foo that a points to though ‘a’ has changed.
a=a+a
print a
print b
14. Explain about string module.
The string module contains number of useful constants and classes, as well as some deprecated legacy
Example:
Program: Output:
find => 6 -1
count => 3
15. Explain global and local scope. (or) Comment with an example on the use of local and global variable
The scope of a variable refers to the places that you can see or access a variable. If we define a variable on
the top of the script or module, the variable is called global variable. The variables that are defined inside a
Example:
def my_local():
a=10
def my_global():
String Slices:
A segment of a string is called string slice, selecting a slice is similar to selecting a character.
Monty
Python
A method is similar to a function. It takes arguments and returns a value. But the syntax is different. For
example, the method upper takes a string and returns a new string with all uppercase letters:
Instead of the function syntax upper(word), it uses the method syntax word.upper()
BANANA
19. Write a Python program to accept two numbers, multiply them and print the result. (Jan-2018)
val1=int(input())
val2=int(input())
prod=val1*val2
20. Write a Python program to accept two numbers, find the greatest and print the result. (Jan-2018)
val1=int(input())
val2=int(input())
if (val1>val2):
largest=val1
else:
largest=val2
Example:
def bar():
pass
If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It
Example:
for x in range(5):
print(x)
This function does not store all the values in memory, it would be inefficient. So it remembers the start,
stop, step size and generates the next number on the go.
The functions that return values, is called fruitful functions. The first example is area, which returns the areaof
def area(radius):
temp = 3.14159 * radius**2
return temp
In a fruitful function the return statement includes a return value. This statement means: Return immediately
from this function and use the following expression as a return value.
Code that appears after a return statement, or any other place the flow of execution can never reach, is called
dead code.
There are three logical operators: and, or, and not. For example, x > 0 and x < 10 is true only if x is greater
than 0 and less than 10. n%2 == 0 or n%3 == 0 is true if either of the conditions is true, that is, if the number
is divisible by 2 or 3. Finally, the not operator negates a boolean expression, so not(x > y) is true if x > y is
false, that is, if x is less than or equal to y. Non-zero number is said to be true in Boolean expressions.
26. Do loop statements have else clauses? When will it be executed? (Nov / Dec 2019)
Loop statements may have an else clause, it is executed when the loop terminates through exhaustion of the
list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a
break statement.
27. Write a program to display a set of strings using range( ) function (Nov / Dec 2019)
for i in range(len(a)):
print(i,a[i])
2. Discuss conditional alternative and chained conditional in detail. (Jan 2019) ------[Page No: 1 to 6]
6. a). Discuss in detail about string slices and string immutability. .(Jan 2019)(or) Analyse String slicing.
Illustrate how it is done in python with example. (May 2019) [Page No: 25 - 28]
b). Write a python code to search a string in the given list. (May 2019)
b) Explain with an example while loop, break statement and continue statement in Python. (10) (Jan
14. a) Write a Python program to find the factorial of the given number without recursion with
b) Write a Python program to generate first ‘N’ Fibonacci series numbers. (Note: Fibonacci numbers are
0, 1,1,2,3,5,8… where each number is the sum of the preceding two).(8) (Jan-2018)
15. (a) If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if
one of the sticks is 12 inches long and the other two are one inch long, you will not be able to get the short
sticks to meet in the middle. For any three lengths, there is a simple test to see if it is possible to form a
triangle. If any of the three lengths is greater than the sum of the other two, then you cannot form a triangle.
i) Write a function named is_triangle that takes three integers as arguments, and that prints either “yes” or
“no”, depending on whether you can or cannot form a triangle from sticks with the given lengths. (4)
ii) Write a function that prompts the user to input three stick lengths, converts them to integers, and uses
is_triangle to check whether sticks with the given lengths can form a triangle. (4)
(b) Write a python program to generate all permutations of a given string using built-in function (8) (Nov /
Dec 2019)
16. (a) Compare lists and array with example. Can list be considered as an array? Justify. (6) (Nov / Dec
2019)
(b) Write a python function Anagram1()to check whether two strings are anagram of each other or notwith
built-in string function and are Anagram2( ) to check the anagram without using built-in string function.
PART- A (2 Marks)
Example:
>>>names = ["Uma","Utta","Ursula","Eunice","Unix"]
>>>for name in names:
print("Hi "+ name +"!")
26. What is mapping?
A list as a relationship between indices and elements. This relationship is called a mapping; each index
“maps to” one of the elements.The in operator also works on lists.
>>> cheeses = ['Cheddar', 'Edam', 'Gouda']
>>> 'Edam' in cheeses
True
>>> 'Brie' in cheeses
False
27. Give a function that can take a value and return the first key mapping to that value in a
dictionary.(Jan 2019)
a={‘aa’:2, ”bb”:4}
print(a.keys()[0])
28. How to create a list in python? Illustrate the use of negative indexing of list with example.
(May 2019)
List Creation:
days = ['mon', 2]
days=[]
days[0]=’mon’
days[1]=2
Negative Indexing:
Example:
>>> print(days[-1])
Output: 2
29. Demonstrate with simple code to draw the histogram in python. (May 2019)
def histogram( items ):
for n in items:
output = ''
times = n
while( times > 0 ):
output += '*'
times = times - 1
print(output)
histogram([2, 3, 6, 5])
Output:
**
***
******
*****
30. How will you update list items? Give one example. (Nov / Dec 2019)
Using the indexing operator (square brackets) on the left side of an assignment, we can update one of thelist
items
fruit = ["banana","apple","cherry"]
print(fruit)
['banana', 'apple', 'cherry']
fruit[0] = "pear"
fruit[-1] = "orange"
print(fruit)
['pear', 'apple', 'orange']
31. Can function return tuples? If yes Give examples. (Nov / Dec 2019)
Function can return tuples as return values.
def circle_Info(r):
#Return circumference and area and tuple
c = 2 * 3.14 * r
a = 3.14 * r * r
return(c,a)
print(circle_Info(10))
Output
(62.800000000000004, 314.0)
2. Discuss in detail about list methods and list loops with examples. ------[Page No: 4, 5]
3. Explain in detail about mutability and tuples with a Python program. . ------[Page No: 10, 11]
4. What is tuple assignment? Explain it with an example. . ------[Page No: 12, 13]
6. Explain in detail about dictionaries and its operations. (or)What is a dictionary in Python? Give example.(4)
7. Describe in detail about dictionary methods. (or) What is Dictionary? Give an example. (4) (May 2019) ----
8. Explain in detail about list comprehension. Give an example. ------[Page No: 20]
9. Write a Python program for
b) insertion sort.
b) quick sort.
11. Appraise the operations for dynamically manipulating dictionaries (12) (Jan-2018)
12. Write a Python program to perform linear search on a list (8) (Jan-2018)
13. Demonstrate with code the various operations that can be performed on tuples. (May 2019)
14. (a) Define Dictionary in python. Do the following operations on dictionaries. (10) (Nov / Dec 2019)
ii) Compare two dictionaries with master key list and print missing keys.
iii) Find keys that are in first and not in second dictionary.
v) Merge two dictionaries and create a new dictionary using a single expression.
15. (a) What is tuple in python? How does it differ from list? (8) (Nov / Dec 2019)
(b) Write a python program to sort n numbers using merge sort (8) (Nov / Dec 2019)
FILES, MODULES, PACKAGES
PART- A (2 Marks)
1. What is a text file?
A text file is a file that contains printable characters and whitespace, organized in to lines separated bynewline
characters.
2. Write a python program that writes “Hello world” into a file.
f =open("ex88.txt",'w')
f.write("hello world")
f.close()
3. Write a python program that counts the number of words in a file.
f=open("test.txt","r")
content =f.readline(20)
words =content.split()
print(words)
4. What are the two arguments taken by the open() function?
The open function takes two arguments : name of the file and the mode of operation.
Example: f = open("test.dat","w")
5. What is a file object?
A file object allows us to use, access and manipulate all the user accessible files. It maintains the state about
the file it has opened.
Example: f = open("test.dat","w") // f is the file object.
6. What information is displayed if we print a file object in the given program?
f= open("test.txt","w")
print f
The name of the file, mode and the location of the object will be displayed.
7. What is an exception?
Whenever a runtime error occurs, it creates an exception. The program stops execution and prints an error
message.
Example:
#Dividing by zero creates an exception:
print 55/0
ZeroDivisionError: integer division or modulo
1
8. What are the two parts in an error message?
The error message has two parts: the type of error before the colon, and specification about the error after
the colon.
Example:
>>> 10 * (1/0)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ZeroDivisionError: integer division or modulo by zero
9. What are the error messages that are displayed for the following exceptions?
a. Accessing a non-existent list item
b. Accessing a key that isn’t in the dictionary
c. Trying to open a non-existent file
a. IndexError: list index out of range
b. KeyError: what
c. IOError: [Errno 2] No such file or directory: 'filename'
10. How do you handle the exception inside a program when you try to open a non-existent file?
filename = raw_input('Enter a file name: ')
try:
f = open (filename, "r")
except IOError:
print 'There is no file named', filename
11. How does try and execute work?
The try statement executes the statements in the first block. If no exception occurs, then except statement is
ignored. If an exception of type IOError occurs, it executes the statements in the except branch and then
continues.
try:
// try block code
except:
// except blcok code
2
Example:
try:
print "Hello World"
except:
print "This is an error message!"
12. What is the function of raise statement? What are its two arguments?
The raise statement is used to raise an exception when the program detects an error. It takes two arguments:
the exception type and specific information about the error.
3
17. What is a package?
Packages are namespaces that contain multiple packages and modules themselves. They are simply
directories.
Example:
import os
os.remove("ChangedFile.csv")
print("File Removed!")
4
21. How do you use command line arguments to give input to the program? (or) What is command line
argument? (May 2019)
Python sys module provides access to any command-line arguments via sys.argv. sys.argv is the list of
command-line arguments. len(sys.argv) is the number of command-line arguments.
Example:
import sys
program_name = sys.argv[0]
arguments = sys.argv[1:]
count = len(arguments)
22. What are the different file operations?
In Python, a file operation takes place in the following order.
1. Open a file
2. Read or write (perform operation)
3. Close the file
23. What are the different file modes?
'r' - Open a file for reading. (default)
'w - Open a file for writing. Creates a new file if it does not exist or truncates the file if it exists.
'x' - Open a file for exclusive creation. If the file already exists, the operation fails.
'a' - Open for appending at the end of the file without truncating it. Creates a new file if it does not
exist.
't' - Open in text mode. (default)
'b' - Open in binary mode.
'+' - Open a file for updating (reading and writing)
24. How to view all the built-in exception in python.
The built-in exceptions using the local() built-in functions as follows.
5
25. What do you mean IndexError?
IndexError is raised when index of a sequence is out of range.
Example:
>>> l=[1,2,3,4,5]
>>> print l[6]
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
print l[6]
IndexError: list index out of range
26. Find the syntax error in the code given:
while True print(‘Hello World’) (Jan 2019)
In the above given program, colon is missing after the condition. The right way to write the aboveprogram
is
while True:
print(‘Hello World’)
27. Categorise the different types errors arises during programming. Interpret the following python
code (May 2019)
>>>import os
>>>cwd = os.getcwd()
>>>print cwd
Syntax Error:
Here in the above given program, Syntax error occurs in the third line (print cwd)
SyntaxError: Missing parentheses in call to 'print'.
6
28. How to use command line arguments in python? (Nov / Dec 2019)
Access to the command line parameters using the sys module. len(sys, argv) contains the number of
arguments. To print all of the arguments str(sys,argv)
29. Write method to rename and delete files ( Nov / Dec 2019)
os.rename(current_file_name, new_file_name)
os.remove(file_name)
1. Write a function that copies a file reading and writing up to 50 characters at a time. (or) Explain the
commands used to read and write into a file with example. (Jan 2019) -------[Page No: 3]
3. Write a python program to count number of lines, words and characters in a text file. (May 2019)
5. Mention the commands and their syntax for the following: get current directory, changing directory, list,
directories and files, make a new directory, renaming and removing directory.
9. Tabulate the different modes for opening a file and briefly explain the same. (Jan-2018) (Jan 2019) ------
[Page No:1 - 2]
10. (a). Appraise the use of try block and except block in Python with example. (6) (Jan-2018)
(b). Explain with example exceptions with argument in Python. (10) (Jan-2018) -------[Page No: 6 to 10]
11. a) Describe how exceptions are handled in python with necessary examples. (8) (Jan 2019, May 2019) -----
7
b) Discuss about the use of format operator in file processing. (8) (or) Explain about the file reading and
writing operations using format operator with python code. (16) (Jan 2019, May 2019) -------[Page No: 3 to
4]
12. (a) What are exceptions? Explain the method to handle them with example. (8) (Nov / Dec 2019) -------[Page
No: 6 to 10]
(b) Write a python program to count the number of words in a text file. (8) (Nov / Dec 2019)
13. (a) How to merge multiple files to a new file using python (6) (Nov / Dec 2019)
(b) What are modules in python? How will you import them? Explain the concept by creating andimporting