End-Term-Sample - Que PYTHON Stions
End-Term-Sample - Que PYTHON Stions
Python Basic
Part A
Q. No. Questions Competence BT Level
1. List the various control flow structures Remember BTL 1
2. Discuss different modes of operation in python. Understand BTL 2
Write a simple python program to perform addition of two
3. Apply BTL3
values.
Discuss why Python is called as dynamic and strongly typed
4. Understand BTL 2
language?
5. Distinguish between string and list data types. Analyze BTL 4
6. Infer how does python interpreter work? Evaluate BTL 5
7. Write an algorithm for basic arithmetic operations. Create BTL 6
8. Evaluate the order of precedence of operators in python. Evaluate BTL 5
9. State Tuple Assignment. Remember BTL 1
10. Define Variable. Remember BTL 1
11. Show how Comment is used in python. Remember BTL1
12. Examine a simple pseudo code to print n integers. Apply BTL 3
13. What is data type in python? List the various data types. Understand BTL 2
14. Draw the flowchart for calculating simple interest. Evaluate BTL 5
15. Write the Pseudo code for greatest among two numbers. Apply BTL3
16. Mention the features of Python. Analyze BTL 4
17. What is Type conversion in python Understand BTL 2
18. Rewrite the following code in Python after removing all syntax Analyze BTL 4
error(s). Underline each correction done in the code
i)
def checkval:
x = input(“Enter a number”) if x % 2 = 0:
print x,”is even”
else if x<0:
print x,”should be positive”
else;
print x,”is odd”
ii)
a = int(input("Value:")) b = 0
for c in range(1,a,2)
b + = c if c%2 = 0:
Print (c*3) Else:
print (c*) print (b)
iii)
1
STRING=""HAPPY NEW YEAR"
for S in range[0,8]:
print(STRING(S))
print( S+STRING)
19. Write Python program to swap two numbers without using Apply BTL3
Intermediate/Temporary variables. Prompt the user for input.
20. Classify expressions by applying different operators. Apply BTL 3
21. Classify different types of statements in python. Analyze BTL 4
22. How do you read an input from a user in Python to be used Analyze BTL 4
as an integer in the rest of the program? Explain with an
example.
23. List the types of operators available in python. Understand BTL 2
24. Which of the following statements produce an error in Remember BTL1
Python?
x, y, z = 1,2,3 # s1
a, b = 4,5,6 # s2
u = 7,8,9 # s3
(List all the statements that have error.)
25. Which of the following can be used as valid and invalid Remember BTL1
variable identifier(s) in Python?
i. 4thSum
ii. Total
iii. Number#
iv. Data
Part B
26. Evaluate the different values (data types) and types of
Evaluate BTL 5
values that can be used in Python.
27. (i) Summarize the advantages and disadvantages of
flowchart. Understand BTL 2
(ii) Summarize the symbols used in flowchart.
28. List the different operators in python and estimate the
Remember BTL 1
precedence of execution.
29. List the types of operators in python and thus explain the
Apply BTL 3
different expressions involved in python.
30. Analyze the need for functions and explain with an
Analyze BTL 4
example.
31. Explain the following.
(i) Tuple assignment
Understand BTL 2
(ii) Comments
(iii) Statements in python
Unit 2
CONTROL FLOW STATEMENTS AND FUNCTIONS
Part A
Q. No. Questions Competence BT
Level
2
1. Define function and state its use. Remember BTL 1
2. What does recursive function implies? Remember BTL 1
3. Evaluate the importance of fruitful functions. Evaluate BTL 5
4. Write a program to check an input number is prime or not. Apply BTL 3
5. Analyze the need to divide a program into functions. Analyze BTL 4
Write a program to print n numbers iteratively using
6. Create BTL 6
function.
Using the concept of functions, calculate the area of a
7. Apply BTL 3
circle.
How pass statement is different from a comment?
8. Remember BTL 1
Write a for loop that prints numbers from 0 to 57, using range
9. Apply BTL 3
function.
Using the concept of tuple assignment, how will you
10. Apply BTL 3
swap two values?
11. What do you mean by fruitful function? Understand BTL 2
12. Outline the scope of variables. Understand BTL 2
13. Write the syntax of if-else statements. Remember BTL 1
14. Differentiate for loop and while loop. Analyze BTL 4
15. List any three built-in functions and its usage. Understand BTL 2
16. Write a function without argument and with return type. Analyze BTL 4
17. Differentiate local and global variables. Apply BTL 3
18. Write a program to find the sum of the digits of a number Evaluate BTL 5
19. Illustrate the flowchart of if-elif-else statements. Apply BTL 3
How would you test the significance of for loop with else
20. Evaluate BTL 5
in an example.
21. Name the type of Boolean operators. Remember BTL 1
22. Describe break statement with an example. Understand BTL 2
23. Write a program to find square root of a given number. Create BTL 6
24. Give the syntax for pass and continue statements. Understand BTL 2
25. Explain following operators of python with suitable Understand BTL 2
examples of each. i)is ii) in iii) not in
Part B
Using the concept of control structure determine the
1. Apply BTL 3
prime numbers in given range using Python.
Write a program to determine the factorial of a given
2. Evaluate BTL 5
number with and without the use of recursion.
What does fruitful function refers to? How it can be
3. Understand BTL 2
used? Explain with an example.
Write the syntax and explain the concept of
4. (i) Recursive function with an example. Remember BTL 1
(ii) to search an element using linear search
3
Explain the looping statements (while and for loops) with
8. Understand BTL 2
an example.
List the different types of conditional control statements
9. Understand BTL 2
and explain them with suitable example.
(i) Write a Python program to find the GCD of given two
10.
numbers.
Apply BTL 3
(ii) Write a Python program to find the exponent of a
number using recursion.
(i). Write a python program to find the greatest among
11.
three numbers.
Understand BTL 2
(ii). Write a program to check the given number is
Armstrong number or not.
Explain with an example break and continue statements
12. Analyze BTL 4
using while loop.
Write a python code to print all numbers in a range
13. Apply BTL 3
(a,b)divisible by a given number (n).
What do you mean by recursion? Write a recursive function to
14. compute the factorial of an input number N.
What is function? How a function is defined and called
15. Remember BTL 1
in python? Explain with a simple program.
(i) Write a Python program to find the sum of N natural
16.
numbers.
Remember BTL 1
(ii) What is the use of pass statement? Illustrate with an
example.
17. (i). Write a Python program using function to find the
sum of first ‘n’ even numbers and print the result.
Analyze BTL 4
(ii). Write a python program to find the roots of the
quadratic equation.
Part C
Create a user defined fruitful function to test a given year
1. Create BTL 6
is a leap year.
Write a function to determine whether a given natural
2. number is a perfect number. A natural number is said to Create BTL 6
be a perfect number if it is the sum of its divisors.
(i). Write a python program to implement student mark
system using chained conditional if control structure.
3. (ii). Write a python program to find the given number is Evaluate BTL 5
positive, negative or zero using Nested if conditional
control structure.
Write a function reads two numbers and evaluates
whether they or co-prime or not. Two numbers are said
4. Evaluate BTL 5
to be co-prime if they do not have any common divisor
other than one.
4
Unit 3
LIST AND TUPLES
Part A
Q. No. Questions Competence BT
Level
1. Define Python list. Remember BTL 1
2. Mention the list operations. Remember BTL 1
3. What are the different ways to create a list? Remember BTL 1
4. Illustrate negative indexing in list with an example. Apply BTL 3
5. How to slice a list in Python? Understand BTL 2
6. Point out the methods that are available with list object. Analyze BTL 4
7. Show the membership operators used in list. Apply BTL 3
8. Define Python Tuple. Remember BTL 1
9. Consider the program: Apply BTL 3
x = ['12', 'hello', 456]
x[0] *= 3
x[1][1] = 'bye'
Explain why this program generates an error.
10. Write a program to add two lists. Create BTL 6
11. What is the difference between Python Arrays and Lists? Understand BTL 2
12. Classify the Python accessing elements in a Tuples. Apply BTL 3
13. Point out the methods used in Tuples Analyze BTL 4
14. How tuple as arguments to a function? Give example. Evaluate BTL 5
15. Write the syntax and purpose of insert( ) method in list. Understand BTL 2
16. How for loop used in sequence objects? Give example. Apply BTL 3
17. Point out the advantages of tuple. Analyze BTL 4
18. Evaluate the difference between lists and tuples. Evaluate BTL 5
19. Show how Tuples are used as return values? Evaluate BTL 5
20. What does sorting refers to? Remember BTL 1
21. What does the term mutability refers to? Understand BTL 2
Write a program to create a list of even numbers in a
22. Create BTL 6
given range.
23. Write the syntax for concatenating two lists in python. Understand BTL 2
24. Show how Tuples are immutable? Understand BTL 2
25. Write a python function named ComputeAverage to find Create BTL 6
average of a list of numbers. It should handle the
exception if the list is empty and return 0 in that case.
With the help of a program, list the different methods in
26. Analyze BTL 4
list.
Part B
5
1. (i) Mention the Python list methods with examples.
(ii) Why it is necessary to have both the functions
append( ) and extend( )? What is the result of the following
expression that uses append( ) where it probably intended Remember BTL 1
to use extend( )?
>>>lst=[1,2,3]
>>>lst.append([4,5,6])
Demonstrate the working of +,* and slice operators in
2. Apply BTL 3
python lists and tuples.
(i) What is a Python Tuple? What are the advantages of
3. Tuple over list? Remember BTL 1
(ii) “Tuples are immutable”. Explain with example.
Illustrate the ways of creating the Tuple and the Tuple
4. Apply BTL 3
assignment with suitable programs.
5. (i) What are the accessing elements in a Tuple? Explain
with suitable programs.
Remember BTL 1
(ii) Explain how to return more than one value from a
function with the help of a program.
(i). Explain the basic Tuple operations with examples.
(ii). Illustrate a program to check whether an element ‘y’
6. and ‘a’ belongs to the tuple mytuple Understand BTL 2
=(‘p’,’y’,’t’,’h’,’o’,n’) and after printing the result, delete
the Tuple.
1. Write a program to perform the following matrix
operations.
Apply BTL 3
(i). Addition of two matrices
(ii). Transpose of a matrix.
How is list used in loops? Give an example each for
2. Understand BTL 2
while loop and for loop used in lists.
3. Given a tuple test_tup = (4, 5, 4, 5, 6, 6, 5). Write a
program to find the frequency of each element. [ Output Evaluate BTL 5
like as {4: 2, 5: 3, 6: 2} ]
Describe the built- i n functions with Tuples and write a
4. program to use Max(), Min() and sorted() methods in Understand BTL 2
Tuple.(13)
5. (i). Discuss a) Tuples as return values b) Variable Length
Argument Tuples
Understand BTL 2
(ii) Write a p r o g r a m t o illustrate t h e comparison
operators in Tuple.
Write a Python program to store ‘n’ numbers in a list and
6. Evaluate BTL 5
sort the list using selection sort.
Using the functions and methods, analyze the differences
7. and similarities of lists and tuples with examples for Analyze BTL 4
each.
Write a program to perform the logic of quick sort
8. Create BTL 6
algorithm.
Describe the behavior of “range (s, e)” in Python.
9. Understand BTL 2
6
Explain the use of “with” construct in Python with an
10. Understand BTL 2
example program.
Part C
1. Write a function that takes a list of numbers as input
Create BTL 6
from the user and produces the corresponding cumulative
list.
2. Write a function to perform sorting of given numbers and
Create BTL 6
present a list of odd and even numbers separately.
3. Write a program to delete all the duplicate elements in a
Evaluate BTL 5
list.
Unit 4
STRINGS, DICTIONARIES & SET
Part A
Q. No. Questions Competence BT Level
1. Define dictionary. Remember BTL 1
2. Examine different set functions. Analyze BTL 4
6. What is set? Remember BTL 1
7. List the dictionary operations. Remember BTL 1
8. List the mutable data types and immutable data types Remember BTL 1
9. How to create and delete a dictionary? Understand BTL 2
10. Write a python program to manipulate strings. Create BTL 6
What will be the output of print(str[2:5]) if str=’hello
11. Evaluate BTL 5
world!’?
12. How to add and remove data in set? Understand BTL 2
13. Write the python code snippet based on string slicing,
which would create a variable called final_string that is
assigned to the word “Bharatiyata” using string1 and
string2?
string1="Bharatdesh"
string2 = "Rastriyata"
Part B
1. (i) Define methods in a string with an example program
using at least 5 methods. Remember BTL 1
(ii) How to access characters of a string?
2. Write a program to count the number of common
Apply BTL 3
characters in a pair of strings.
3. Describe the methods and operations of Dictionaries. Remember BTL 1
4. Write a Python program to count the number of vowels
Understand BTL 2
in a string provided by the user.
5. Write a program that takes a sentence as input from the
user and computes the frequency of each letter. Use a Apply BTL 3
variable of dictionary type to maintain the count.
6. Python strings are immutable. Justify with an example
Analyze BTL 4
program.
7
7. (i) Analyze string slicing. Illustrate how it is done in
python with an example.
(ii) Write a python code to search a string in the given Analyze BTL 4
list.
Unit 5
File Handling, Exception Handling ,Object Oriented Programming & Miscellaneous
Problems
Part A
Q. No. Questions Competence BT
Level
1. Point out different modes of file opening. Analyze BTL 4
2. Define the access modes Remember BTL 1
3. Distinguish between files and modules. Understand BTL 2
4. Define read and write file Remember BTL 1
5. Describe renaming and deleting a file in python. Understand BTL 2
6. Discover the format operator available in files. Apply BTL 3
7. Examine the need for exceptions using an example Analyze BTL 4
8. Explain Built-in exceptions. Evaluate BTL 5
8
Difference between built-in exceptions and handling
9. Remember BTL 1
exception
Write a program to write a data in a file for both write
10. Evaluate BTL 5
and append modes.
11. How to import statements? Remember BTL 1
Find the error in the code given:
12. Create BTL 6
while True print (‘Hello world’)
13. Define package. Remember BTL 1
14. What are packages in Python? Remember BTL 1
Write the difference between read( ) and read(n)
15. Evaluate BTL 5
functions?
Accept five names from the user and write in a file
16. Analyze BTL 4
“name.txt”.
17. What is ‘value error’ in python? Apply BTL 3
18. What is base exception? Understand BTL 2
19. Examine buffering. Apply BTL 3
20. What do you mean by fileisatty() method Understand BTL 2
21. Discover except Clause with Multiple exception Apply BTL 3
Create a Python script to display the current date and
22. Create BTL 6
time.
23. Analyze the object as return values. Analyze BTL 4
24. Discuss a modular design Understand BTL 2
26. State which of the following python statements are valid and
invalid.
9
xv) In order to extend a class, the new class should
have access to all the data and inner workings of
the parent class.
xvi) def __init__(self, title, author): is the correct
way to define an initializer method.
Part B
Write a Python program to demonstrate the file I/O
1. Analyze BTL 4
operations.
for i in range(4):
skk.forward(50)
skk.right(90)
turtle.done()
d) class test:
def __init__(self,a="Hello World"):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
e) y = 6
z = lambda x: x * y
print (z(8))
f) x = ['ab', 'cd']
print(len(list(map(list, x))))
g) import turtle
h) t=turtle.Pen()
for i in range(0,4):
t.forward(100)
t.left(90)
t.penup()
t.left(90)
t.forward(200)
for i in range(0,4):
t.forward(100)
t.left(90)
i) class People():
def namePrint(self):
11
print(self.name)
person1 = People("Sally")
person2 = People("Louise")
person1.namePrint()
Part C
Create a program to compute price per unit weight of an
1. Create BTL
item using try – except – else block.
6
Write a program that reads the contents of the file text.txt and
counts the number of alphabets, blank spaces, lowercase letters
2. and uppercase letters, the number of Create BTL
words starting with a vowel, and the number of occurrences of the 6
word ‘is’ in the file.
12
Write a function that reads a file file1 and evaluates and
4. Evaluate BTL 5
displays number of words and vowels in the file.(15)
13