0% found this document useful (0 votes)
25 views3 pages

Python Programming Concepts and Exercises

The document outlines a computer science test with questions related to Python programming, covering topics such as data types, functions, loops, tuples, dictionaries, and file handling. It includes specific tasks like writing scripts for Fibonacci series and palindrome checks, as well as explaining key concepts and methods. The test is structured into multiple questions with varying marks, emphasizing practical coding skills and theoretical understanding.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Python Programming Concepts and Exercises

The document outlines a computer science test with questions related to Python programming, covering topics such as data types, functions, loops, tuples, dictionaries, and file handling. It includes specific tasks like writing scripts for Fibonacci series and palindrome checks, as well as explaining key concepts and methods. The test is structured into multiple questions with varying marks, emphasizing practical coding skills and theoretical understanding.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CS TEST

MM: 75 TT:3HR
Q1 Answer any five the following: (5x5=25)
a. Explain the key features of Python?
b. Explain Mutable and Immutable Data types with example.
c. Consider a list L- (10, 20,30, 40]. Find the output of following statements.
1. L[0] = L[0]+2
2. L= L+2
3. L= L*2
4. L[1] = 50
5. L = L[::-1]
d. Explain the following functions with example.
i) update()
ii) copy()
e. Explain the Dynamic Typing feature of Python with example.
f. Write the difference between indexing and slicing with example
Q2
a) Explain the following terms:- (3.5)
1. Continue
2. Pass
b) Write a python script to print Fibonacci series for first 20 elements. (4)
c) Explain Entry - Controlled loops in Python with the help of programs. (5)
OR
a. What is the difference between interactive mode and script mode in python? (3)
b. Write a program that reads a string and check whether it is a Palindrome or not. (5)
c. Explain the following functions with example. (4.5)
a. Swapcase()
b. isspace()
c. Lstrip()
Q3
a. What is Tuple? How to define and access the elements of Tuple? Explain it with a
code. (6)
b. What is the output of the following code snippets. (4)
1. t1 = (3)
t2= (4,5,6)
t3= t1 +t2
print(t3)
2. d = dict()
d[‘left’]='>’
d[‘right’]= '<’
print(d['left'] and d['right’] or d['right'] and d['left'])
print(d[‘left'] and d['right'] and d[‘right'] and d['left’] )and d['end']).
c. How are Dictionaries different from list? (2.5)
OR
a. What is Dictionary? What are the different ways to create Dictionary? (5)
b. Explain the following methods of Lists with example: (4)
1. extend() 2. insert()
c. Given a tuple namely City storing cities names (‘tokoyo', 'Delhi' ,'Seoul', '
Jaipur', 'Paris', 'Luxembourg, 'Berlin', 'London', 'Moscow) as elements. Write
a program to print names of the cities as well as their index in the index
range 2 to 6, both inclusive . (3.5)
Q4
a. What is function? Explain the different types of arguments in function in Python.
Illustrate with the help of programs. (6.5)
b. Predict the output of the following code snippet: (2)
def add(a,b,c):
print(x+y+z)
c= add(6,16,26)
c. Write a program to find factorial of a number using recursion. (4)
OR
a. What is the difference between Package and Module? What are the different ways
to import a module in a program? (5)
b. Write a program that reads a number, then converts it into octal and hexadecimal
equivalent using built-in functions of Python. (3.5)
c. Differentiate between local and global variables in python with the help of a
program. (4)
Q5.
A. Explain the following built-in methods of file. (6)
(i) read(n)
(ii) seek()
(iii) writelines()
(iv) tell()
B. What is an Exception. Explain the different types of Exceptions/Errors in python and
how to raise an exception. (4.5)
OR
a. Explain the different file opening modes with example. (8)
b. Explain the concept of try – except and finally block with example. Can there be
multiple except statements explain with example. (4.5)

You might also like