Program MCA
Semester II
Course V24PCA201-Python Programming
Unit 1
PART (A) - (10 MCQ = 10*1M)
1. Who developed Python?
a) Dennis Ritchie
b) James Gosling
c) Guido van Rossum
d) Bjarne Stroustrup
Answer: c
2. Which of the following is a valid variable name?
a) 1var
b) var_1
c) var-1
d) @var
Answer: b
3. Which data type is immutable?
a) List
b) Dictionary
c) Set
d) Tuple
Answer: d
4. Which symbol is used for comments in Python?
a) //
b) /* */
c) #
d) --
Answer: c
5. Tuple is defined using:
a) []
b) {}
c) ()
d) <>
Answer: c
6. Which keyword is used for decision making?
a) for
b) while
c) if
d) loop
Answer: c
7. Which loop is used to iterate over a sequence?
a) if
b) for
c) break
d) pass
Answer: b
8. Dictionary stores data in:
a) Key-value pairs
b) Index
c) Values only
d) None
Answer: a
9. Which of the following is correct function syntax?
a) def fun()
b) function fun()
c) fun def()
d) define fun()
Answer: a
10. Syntax of lambda function:
a) lambda x: x+1
b) def lambda(x)
c) function lambda(x)
d) lambda = x+1
Answer: a
PART (B) - ( 5 Short Answer Questions =5*5 M)
[Link] the working of the Python Interpreter.
[Link] between List, Tuple, and Set with examples.
[Link] control flow statements in Python with suitable examples.
[Link] Python dictionaries and their operations with examples.
[Link] functions and lambda expressions in Python with examples.
PART (C) - (2 Long Answer Questions = 2*10 M)
1. Explain Python data types and sequences in detail.
2. Discuss lambda functions and filter() in Python.
Unit 2
PART (A) - (10 MCQ = 10*1M)
1. Output of:
[x for x in range(5)]
a) [1,2,3,4,5]
b) [0,1,2,3,4]
c) [0,1,2,3,4,5]
d) Error
Answer: b
2. List comprehension is used to:
a) Create lists efficiently
b) Delete lists
c) Sort lists
d) Reverse lists
Answer: a
3. Which function is used to open a file?
a) file()
b) open()
c) read()
d) write()
Answer: b
4. Which mode is used to append data?
a) r
b) w
c) a
d) x
Answer: c
5. Which keyword is used to import modules?
a) include
b) import
c) using
d) require
Answer: b
6. Which method is used as constructor?
a) start
b) init
c) create
d) main
Answer: b
7. Inheritance allows:
a) Code reuse
b) Code deletion
c) Code duplication
d) None
Answer: a
8. Which block is used to handle exceptions?
a) try
b) catch
c) except
d) handle
Answer: c
9. Which function converts string to uppercase?
a) upper()
b) capitalize()
c) lower()
d) title()
Answer: a
10. Regular expressions are used for:
a) Arithmetic operations
b) Pattern matching
c) File handling
d) Looping
Answer: b
PART (B) - ( 5 Short Answer Questions =5*5 M)
[Link] iteration in Python using for and while loops with examples.
[Link] list and dictionary comprehensions with suitable examples.
[Link] file handling in Python.
[Link] classes and objects in Python with an example.
[Link] exception handling in Python.
PART (C) - (2 Long Answer Questions = 2*10 M)
[Link] Object-Oriented Programming in Python.
[Link] user-defined exceptions and exception handling mechanisms in detail.
Unit 3
PART (A) - (10 MCQ = 10*1M)
1. Which module is used to interact with the operating system?
a) sys
b) os
c) file
d) system
Answer: b
2. Which function returns the current working directory?
a) [Link]()
b) [Link]()
c) [Link]()
d) [Link]()
Answer: b
3. Which function is used to create a directory?
a) [Link]()
b) [Link]()
c) [Link]()
d) [Link]()
Answer: a
4. Which list stores command-line arguments?
a) [Link]
b) [Link]
c) [Link]
d) [Link]
Answer: a
5. Which function is used for directory tree traversal?
a) [Link]()
b) [Link]()
c) [Link]()
d) [Link]()
Answer: b
6. Which module helps in file path operations?
a) [Link]
b) [Link]
c) [Link]
d) path
Answer: a
7. Which function checks if a file exists?
a) [Link]()
b) [Link]()
c) [Link]()
d) [Link]()
Answer: b
8. Which module is used for multithreading?
a) thread
b) threading
c) multi
d) parallel
Answer: b
9. Python supports parallel execution using:
a) Threads
b) Processes
c) Both
d) None
Answer: c
10. Scripts in Python are:
a) Compiled programs
b) Executable Python files
c) Machine code
d) Assembly code
Answer: b
PART (B) - ( 5 Short Answer Questions =5*5 M)
[Link] the OS module in Python.
[Link] the sys module and its uses.
[Link] directory traversal in Python.
[Link] threading in Python.
[Link] command-line arguments and environment variables in Python.
PART (C) - (2 Long Answer Questions = 2*10 M)
[Link] system interfaces in Python.
[Link] binary files and program execution control in Python.
Unit 4
PART (A) - (10 MCQ = 10*1M)
1. Which module is used for socket programming in Python?
a) os
b) sys
c) socket
d) net
Answer: c
2.A socket is an endpoint of:
a) File
b) Communication
c) Program
d) Loop
Answer: b
[Link] method accepts a connection?
a) listen()
b) accept()
c) connect()
d) bind()
Answer: b
[Link] method is used in client side to connect?
a) bind()
b) connect()
c) listen()
d) accept()
Answer: b
[Link]-side scripting runs on:
a) Client
b) Server
c) Browser
d) None
Answer: b
[Link] stands for:
a) Common Gateway Interface
b) Computer Gateway Interface
c) Common General Interface
d) Code Gateway Interface
Answer: a
[Link] method sends data via:
a) Body
b) URL
c) Header
d) File
Answer: b
[Link] stands for:
a) Extended Markup Language
b) Extensible Markup Language
c) Extra Markup Language
d) External Markup Language
Answer: b
[Link] parser is:
a) Tree-based
b) Event-based
c) Loop-based
d) Object-based
Answer: b
10. Socket communication requires:
a) Port and IP
b) File
c) Loop
d) Variable
Answer: a
PART (B) - ( 5 Short Answer Questions =5*5 M)
[Link] socket programming in Python with basic steps.
[Link] client-side and server-side scripting with examples.
[Link] CGI scripts with user interaction.
[Link] urllib module and its uses.
[Link] XML parsing using SAX parser.
PART (C) - (2 Long Answer Questions = 2*10 M)
[Link] server-side scripting and CGI in detail.
[Link] XML parser architectures and APIs.
Unit 5
PART (A) - (10 MCQ = 10*1M)
1. Tkinter is a:
a) Module
b) Package
c) Class
d) Function
Answer: a
2. Top-level windows are created using:
a) Frame()
b) Toplevel()
c) Window()
d) Box()
Answer: b
[Link] widget is used for:
a) Display text
b) User input
c) Image
d) File
Answer: b
[Link] is used for:
a) Navigation
b) Input
c) Output
d) Loop
Answer: a
[Link] are:
a) Errors
b) User actions
c) Functions
d) Variables
Answer: b
[Link] method handles button action?
a) command
b) action
c) run
d) execute
Answer: a
[Link] is a:
a) Programming language
b) Database
c) OS
d) Compiler
Answer: b
[Link] module is used for SQLite in Python?
a) sql
b) sqlite3
c) db
d) database
Answer: b
[Link] scripts are used for:
a) Real-time tasks
b) Only theory
c) Only GUI
d) None
Answer: a
[Link] load scripts are used for:
a) GUI
b) Loading data into database
c) Loop
d) File
Answer: b
PART (B) - ( 5 Short Answer Questions =5*5 M)
[Link] Tkinter and its features.
[Link] top-level windows and dialogs in Tkinter.
[Link] event handling in Tkinter with examples.
[Link] SQLite database connection and operations in Python.
[Link] Python data structures (list, tuple, dictionary) with examples.
PART (C) - (2 Long Answer Questions = 2*10 M)
[Link] SQLite database integration with Python.
[Link] a simple Python application using Tkinter.