0% found this document useful (0 votes)
146 views7 pages

Python Programming Question Bank

KJBKVDXBND

Uploaded by

shantanupote40
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views7 pages

Python Programming Question Bank

KJBKVDXBND

Uploaded by

shantanupote40
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lOMoARcPSD|34889173

PWP uniwize QB - Python imp questions

Advance Java Programming (Zeal College of Engineering and Research)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Darshan Gaming ff (gtotal663@[Link])
lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

Unit 1: INTRODUCTION AND SYNTAX OF PYTHON PROGRAM (08 MARKS)


2 Marks
1. Explain numeric data types in Python.
2. Differentiate between interactive mode and script mode of Python.
3. List different Object Oriented Features supported by Python.
4. Describe Python Interpreter.
5. Enlist applications for Python programming.

4 Marks
1. Explain any 4 features of Python programming
2. Write steps to install Python and to run Python code.
3. List and Explain different data types used in Python.
4. Describe the role of indentation in Python.
5. Define the following terms:
i. Identifier
ii. Literal
iii. Keyword
iv. Variable
6. List the features of Python and explain any two.
7. What do you mean by variable? Does Python allow explicit declaration of variables? Justify
your answer.
8. What is comment? How to apply comments in Python?
9. Explain numeric data-types in Python.
10. Explain the use of strings in Python. Also explain ‘+’ and ‘*’ w. r. t. string.

Downloaded by Darshan Gaming ff (gtotal663@[Link])


lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

Unit 2. PYTHON OPERATORS AND CONTROL FLOW STATEMENTS (10 MARKS)


2 Marks
1. Write Syntax of if-else and if-elif -else statement in Python.
2. State the use of keyword pass.
3. List and write the use of Identity Operators
4. Write the syntax of while loop and for loop.
5. Explain continue and break statement with syntax.
6. List and write the use of membership operators in Python.
4 Marks
1. Explain logical and bitwise operators in Python with appropriate example.
2. Explain relational and arithmetic operators in Python with examples.
3. Write a Python program to print factorial of a number. Take input from user.
4. Write a Python program to print Fibonacci series up to n terms.
5. Write a Python program to check whether given Number is even or odd.
6. Explain arithmetic operators in Python with an example.
7. Explain bitwise operators in Python with an example.
8. Explain membership operator and identity operators in Python with examples.
9. Explain if-else statement with example.
10. Show the use of keyword elif in Python with example.
11. How to use short-hand if-else statement in Python. Explain with example.
12. Explain for-loop in Python with example.
13. Can we use keyword else with any loop? Justify your answer.
14. State the use of keyword pass.
15. Explain the use of keywords break and continue in Python.

Downloaded by Darshan Gaming ff (gtotal663@[Link])


lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

Unit 3. DATA STRUCTURE IN PYTHON (14 MARKS)


2 Marks
1. Can we delete list elements? Justify your answer.
2. Define tuple in Python? How to create and access it?
3. Compare list and tuple.
4. Enlist built in function in dictionaries and explain any two.
5. Explain any two built in methods of set in Python with example.
6. Can we delete the list element?
7. Explain the use of keywords del w.r.t list.
4 Marks
1. Describe basic operations perform on list with example.
2. Explain any four built in methods of lists in Python with example.
3. Explain the basic operations that can be performed on tuple.
4. Enlist built in function in tuple and explain any four.
5. Explain the basic operations that can be performed on set in Python with suitable example
6. Explain the basic dictionaries operations with an example.
7. How to declare the list? Can we change or update the list elements? Justify your answer.
8. Write a short note on slicing list.
9. Explain the following function w.r.t list a) append() b) insert()
10. How to declare the tuple? Can we change or update the tuple? Justify your answer.
11. How to declare the set? Can we change iterate through set by using while loop? Justify
your answer.
12. Can we iterate through set by using for loop? Justify your answer.
13. Can we add new elements in set? Justify your answer with example.
14. Explain the following set operations
a) Set union b) Set intersection c) Set symmetric difference
15. How to declare the dictionary in Python?
16. Explain different ways and function to remove key:value pair from dictionary

Downloaded by Darshan Gaming ff (gtotal663@[Link])


lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

4. PYTHON FUNCTIONS, MODULES AND PACKAGE (14 MARKS)


2 Marks
1. Describe User-defined Function in Python.
2. Define Module in Python? How to create a module and use it.
3. Write different types of arguments in a function.
4. Explain from...import statement.
5. Shows the use of reduce function with an example.
6. State the use of keyword global with simple example.
7. Explain Data Conversion functions in Python.
8. Can Python function return the value? Justify your answer with example.
4 Marks
1. Define Package? Write the steps to create a package in Python?
2. Explain type conversion of variable in Python. Explain any four data conversions functions.
3. Write a function that takes single character and prints “character is vowel‟ if it is vowel,
“character is not vowel‟ otherwise.
4. Write a Python program to calculate factorial of given number using recursive function.
5. Write a Python program to find reverse of a given number using user defined function.
6. Explain the following package with suitable example.
i) numpy ii) scipy iii) pandas iv) matplotlib
7. Explain Python built in module.
i) Numeric and Mathematical Module.
ii) Functional Programming Module
8. Define function. How to create user-defined function in Python?
9. Explain the concept of parameter passing to Python function.
10. Can Python function return the value? Justify your answer with example.
11. Define and explain local variables and global variables with suitable examples.
12. Write a Python program to demonstrate variable length arguments. Also explain that program.
13. How to create the module in Python?
14. Explain Python built-in module: random
15. Explain use of lambda expression with example.
17. Explain the use map function with example.
18. Write a program to create bar chart using matplotlib

Downloaded by Darshan Gaming ff (gtotal663@[Link])


lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

Unit 5. OBJECT ORIENTED PROGRAMMING IN PYTHON (12 MARKS)


2 Marks
1. Define class? How to create an class and its object in Python.
2. State the use of parameter “self” in Python class.
3. Differentiate between method overloading and method overriding.
4. Explain Destructor in Python.
5. Describe Data Hiding.
6. Explain constructor function in Python class with example.
4 Marks
1. Write a program to demonstrate parameterized constructor in base class and derived class
2. Write a program to demonstrate constructor with default arguments.
3. Write a program to create a Python class and delete object of that class using del keyword.
4. Explain inheritance in Python with example.
5. Create a class employee with data members: name, department and salary. Create suitable
methods for reading and printing employee information.
6. Explain data abstraction in detail.
7. Describe term composition classes with example.
8. What is class? How to declare class in python?
9. State the use of parameter ‘self’ in python class.
10. Explain constructor function in python class with example.
11. Can we overload constructor function in python? Justify your answer.
12. Can we call constructor and destructor function manually in python? Justify your
answer.
13. Write a program to demonstrate parameterized constructor in base class and derived
class.
14. How to create abstract method in python? Explain with example.
15. Python dose not allowed method overloading. Then explain alternate ways of
achieving the similar effect of overloading.
16. Write a short note on method overriding in python.

Downloaded by Darshan Gaming ff (gtotal663@[Link])


lOMoARcPSD|34889173

ZEAL EDUCATION SOCIETY’S


ZEAL POLYTECHNIC, PUNE
NARHE │PUNE -41 │ INDIA
COMPUTER ENGINEERING DEPARTMENT
Course: - Programming with Python 22616

Unit wise Question Bank

Unit 6. FILE I/O HANDLING AND EXCEPTION HANDLING (12 MARKS)


2 Marks
1. List four file modes in Python.
2. Explain open() and close() methods for opening and closing a file.
3. Write use of try: finally block with Syntax.
4. Describe print() functions with example.
5. Give the syntax and significance of input() method.
6. State the use of read() and readline() function in Python file handling mechanism.
7. State the use of write() and writeline() function in Python file handling mechanism.
4 Marks
1. Explain with an example, how to rename or delete File or Directory.
2. Explain exception handling with example using try, except, raise keywords.
3. Explain how to create a user defined exception with an example.
4. Write a Python program which will throw exception if the value entered by user is less than
zero.
5. Write a Python program to read contents of [Link] file and write same content in [Link]
file.
6. Explain following Python functions:
i. getcwd() ii. mkdir() iii. chdir() iv. listdir()
7. Explain print() function with its arguments.
8. Explain following file related operations:
a) Opening a file b) writing into a file using write() function
c) reading from a file using readline() function
9. How to create user defined exception and raise it manually? Explain with example.
10. Explain following python function w.r.t Dictionary.
a) getcwd() b) mkdir() c) chdir() d) listdir() e) exist()
11. Explain rename() and remove() function w.r.t Dictionary.
12. Explain use of try : except block with example.
13. Write a program to demonstrate try with multiple exception.
14. Explain except: block without any exception name to it.
15. Can a single except: block handle multiple exception.
16. How to manually raise an exception? Explain with example.

Downloaded by Darshan Gaming ff (gtotal663@[Link])

Common questions

Powered by AI

Python uses indentation to define blocks of code, like those for functions, loops, and conditional statements, instead of curly braces or keywords used in other languages. This approach enforces a clean and visible code structure, making it unique and improving readability. The strict requirement for consistent indentation forces developers to format code properly, reducing interpretation and readability errors. However, this can be challenging for beginners transitioning from languages with flexible syntax styles .

Python functions can have several types of arguments: positional arguments, which are mandatory; keyword arguments, which are optional and allow specification by name; default arguments, which assume default values if no value is provided; and variable-length arguments, which allow passing a variable number of arguments using *args for non-keyword and **kwargs for keyword-based arguments. For example, 'def function(arg1, arg2, kwarg1=None, *args, **kwargs):' utilizes all these types, supporting flexible function calls and extensions .

Lists in Python are mutable, meaning that their contents can be changed (added, removed, or modified). Tuples, on the other hand, are immutable, which makes them faster to access and suitable for read-only operations or as constant data storage. Lists are preferable when data needs frequent modifications. Tuples are preferable when the integrity of data is crucial, especially to use as dictionary keys, since they are hashable .

Python's dynamic typing means that a variable's type is determined at runtime, and different types can be assigned to the same variable at different times. This flexibility eliminates the need for explicit declaration seen in statically typed languages, allowing programmers to focus more on logic rather than declaration and types. Although Python does not require explicit variable declaration, recent versions support type hints for better code clarity and maintainability, yet they are not enforced at runtime .

User-defined functions in Python are created by the programmer to execute specific tasks, improving modularity and code reusability. They are defined using the 'def' keyword and can take arguments and return values. Built-in functions are provided by Python at runtime, such as 'print()' and 'len()', offering common functionality. An example of a user-defined function is 'def add(a, b): return a + b', which returns the sum of two numbers. Unlike built-ins, user-defined functions serve custom requirements not covered by the language's standard library .

Python does not support method overloading directly, as it does not have a function signature mechanism like other languages. To achieve similar functionality, developers can use default arguments, keyword arguments, or variable-length arguments to allow a function to accept different types or numbers of inputs. Another strategy is to check the type or quantity of arguments inside the function and then implement different behaviors depending on the inputs .

The 'if-elif-else' structure in Python allows for multi-way branching in the code. The 'if' statement is used to test a condition. If the condition is true, the block inside 'if' is executed. 'Elif' stands for 'else if' and allows checking multiple expressions. If a condition for 'elif' is true, the corresponding block will be executed. An 'else' statement is present to execute a block when none of the conditions is true. Syntax requirements include proper indentation and colon (:) after each conditional statement .

The 'try-except' block in Python handles exceptions in the code. Code that might cause an exception is placed inside the 'try' block, and if an error occurs, the 'except' block is executed. An 'else' block follows 'except' and is executed if no exceptions were raised in the 'try' block. This structure allows developers to manage errors concisely and separate error-handling logic from normal code execution .

Logical operators in Python (and, or, not) are used to combine conditional statements. For example, 'if (a > 0 and b < 5):' checks if both conditions are true. Bitwise operators (&, |, ^, ~, <<, >>) operate on bits and are used for operations on binary numbers. For example, the expression 'a & b' performs a bit-by-bit logical AND operation. Logical operators work at a higher abstraction level, dealing with boolean logic, while bitwise operators work at the binary level .

The 'self' keyword in Python is used within methods to refer to the instance of the class on which the method is being called. It's how the method accesses attributes and methods within the class. By convention, 'self' is the first parameter in a class method, although it can be named differently. It is critical as it allows differentiation between instance variables and local variables within methods, enabling object-specific data handling .

You might also like