Government Engineering College, Patan
Electronics & Communication Engineering
Department
Subject: Python Programming
Chapter 1
1. Introduction to Python
1. Define Python. List the important features of Python.
2. What are key features of Python?
3. What is the significance of setting the environment variable PATH during Python
installation? How does it affect running Python from the command line?
4. Differentiate between compiler and interpreter. How is Python an interpreted language?
5. What are keywords in Python?
6. What are the rules for naming a variable in Python?
2. Python Data Types & Variables
1. What is Data Type? Explain various data types used in Python.
2. What are common built-in data types in Python?
3. Describe the various data types in Python (e.g., integer, float, string, boolean, list, tuple,
dictionary). How does Python manage memory allocation for these data types?
4. What are local variables and global variables in Python?
3. Operators in Python
1. Describe mathematical and logical operators in Python.
2. Write a short note on different types of operators in Python with appropriate examples.
3. Describe Arithmetic Operators, Assignment Operators, and Bitwise Operators in detail
with examples.
4. Write a short note on: Bitwise operators in Python.
5. Explain various arithmetic and logical operators in Python.
6. Describe membership operator and identity operator with example.
7. Demonstrate membership operators and identity operators with suitable examples.
8. Explain the is and is not operators with example.
9. What is the difference between == and is operator in Python?
10. Explain and categorize operators in Python.
11. Enlist Python operators which result in Boolean output. Explain with example.
12. Explain modulo operator in Python with the help of suitable example.
4. Control Structures & Errors
1. What is different type of error in Python? Explain in brief.
2. List and explain in brief different types of errors occurred in Python.
3. Enlist Python errors. Describe try-except block with example.
5. Strings in Python
1. What is the use of str.upper() and str.lower() functions in string?
2. What is len function and explain how it is used on strings with an example.
3. Explain string comparison with an example.
4. Explain how string is converted into list? Convert string S = “GTU Supports Innovation”
into list.
5. Describe slicing in Python. How does it work with lists, tuples, and strings? Provide
examples to illustrate the slicing syntax.
6. Lists, Tuples, and Sets
1. Explain the following List methods in Python with appropriate example:
a) append() b) insert() c) remove() d) clear() e) reverse()
2. Discuss the following functions of List in Python:
a) append() b) count() c) reverse()
3. Describe the following List methods with example:
a) append() b) insert() c) discard()
4. What are negative indexes and why are they used?
5. What is tuple? What is the difference between list and tuple?
6. Differentiate between List and Tuple.
7. How is a list different from a tuple? Write advantages of tuple.
8. Give comparison between Tuple and List in Python.
9. Describe Python tuple with example. Describe any two built-in tuple methods.
10. Describe concept of “set” in Python. How to access individual members of set?
11. What is set in Python? Explain various methods that can be used with sets in Python.
12. Differentiate List, Tuple, Set and Dictionary.
7. Dictionaries
1. Describe dictionary example in Python. How to access individual members?
2. What are Python's dictionaries? Explain how to create a dictionary in Python.
3. Explain dictionary in Python with suitable example.
4. Describe different methods to make dictionary variable.
5. How does del operation work on dictionaries? Give an example.
6. Explain dictionary in detail.
7. What are the restrictions on dictionary keys in Python? Can a dictionary key be mutable?
Explain why or why not with an example.
8. Type Conversion
1. What is type conversion in Python? Explain with the help of suitable example.
2. Explain various type conversion functions in Python.
3. What is type conversion in Python? Differentiate between implicit and explicit type
conversion with examples.
4. Explain the conversion of list to dictionary in Python.
9. File Handling
1. Enlist different modes of opening file. Describe any three methods with example.
10. Miscellaneous
1. Describe merits and demerits of Python over other languages.
2. Discuss the advantage and disadvantage of Python.
3. List the advantage and disadvantage of Python.
4. What are the advantages of choosing mnemonic variable names in Python?
Chapter 2
1. Looping & Control Statements
1. Describe break, continue, pass statement with example
2. Explain break and continue statement in Python?
3. Explain continue and pass statements in Python with example. What is the use of
continue and pass statements?
4. Explain the use of pass, break and continue statement in Python.
5. Explain the structure of for loop in Python with suitable example
6. Explain the structure of while loop in Python.
7. Explain for loop in Python. Display even numbers from 0 to 100 using for loop
8. Explain while loop in Python. How to create infinite while loop? How to break infinite
while loop in certain condition? Explain with example.
9. Explain nested if statements in Python with logical combinations. (Temperature &
Humidity program)
10. Explain nested if else statement in Python
11. Explain the difference between if, if...else, and elif statements in Python. Provide an
example where each is used.
12. Make use of if, if..else, if..elif..else, and nested if.
13. Explain for loop in detail.
14. Explain while loop in detail.
15. Explain working of break, continue and pass statement.
16. Describe range function with example.
17. What is an infinite loop in Python? How can you detect and break out of an infinite loop
in your code?
18. What are the risks of using while loops, and how can you avoid creating an infinite loop?
Provide example.
19. Explain the purpose of the break statement in Python. How does it affect loop
execution? Provide example.
2. Conditional Statements & Logical Operations
1. Explain Logical Operator and Bitwise Operator in Python.
2. Explain arithmetic operator and assignment operator in Python.
3. Pattern Printing
1. Write Python code to print the following pattern using nested loop:
*
**
***
****
*****
2. Write a Python program to generate pyramid pattern:
*
**
***
****
3. Write Python code to print pattern:
1
01
101
0101
10101
4. Develop Python program to construct following pattern:
*
**
***
****
*****
****
***
**
*
4. Python Programs (Logic-based)
1. Write Python code to find and print first n Fibonacci numbers.
2. Write Python code to find average, Maximum and Minimum of marks (class size: 60).
3. Write a Python program to check if a string is palindrome or not.
4. Write a program to enter a number and print its octal and hexadecimal equivalent.
5. Write a Python program to find factorial of any number.
6. Write a Python program that accepts a sentence and calculates number of words, digits,
uppercase & lowercase letters.
7. Write a Python Program to find the sum of all odd numbers up to a number specified by
the user.
8. Write Python Program to get number from user and find the sum of digits.
9. Write Python Program to check if a given year is a leap year.
10. Write Python Program to input info for 5 students (Name, Reg No, Total Marks).
11. Write Python Program to prompt for marks and print grade based on criteria.
12. Write Python Program to count number of times an item appears in a list.
13. Given point (x, y), find whether it lies in which quadrant.
14. Write Python Program to check validity of a password with given criteria.
15. Write a Python program to print all prime numbers between 100 and 200.
16. Write a Python program to multiply all numbers in a list.
17. Write a Python function to sum all numbers in a list.
18. Write Python program to find sum of first N numbers using while loop.
19. Write Python code to find determinant of 3x3 matrix (runtime input).
20. Develop Python program to print even numbers in a list.
21. Develop Python program to count occurrences of element in a list.
22. Write a Python program to compute sum, difference, product, and quotient of two
numbers.
23. Write a Python program to do list operations: append, remove, sort, reverse, print.
24. Write a Python program to: create tuple, access elements, slice, and try modifying
element (explain immutability).
5. Code Output & Syntax Understanding
1. What is the output of the following code snippet? (fred & jane functions)
2. What is the purpose of “def” keyword in Python?
3. Write the output of the given code:
txt = "Python Programming"
x = txt.casefold()
print(x)
y = txt.count("P")
print(y)
x = txt.split()
print(x)
Chapter 3
1. Functions in Python
1. What is a function? Mention the type of function and use.
2. Describe user defined function in Python.
3. Explain the purpose of defining custom functions in Python. How do functions contribute
to code reusability and organization? Provide an example of a function that calculates the
factorial of a number.
4. Differentiate actual and formal arguments.
5. Define SCOPE, Discuss global and local variable in detail.
6. Discuss global, local and nonlocal variable in detail.
7. Describe Python function with keyworded variable length argument with example.
8. Describe lambda function with two examples.
9. Define Lambda function, Utilize lambda function in an example.
10. Describe filter method/function available in Python with example.
11. Write a Python function to sum all the numbers in a list.
12. Write a Python function to convert string into upper case and find length of string. String
will be passed to function from main program and print both the return values in main
program.
13. Write following Python functions:
Function-1: Returns reverse string word wise.
Function-2: Count occurrence of vowels from input string. Design main Python code where
above functions are called.
14. Develop Python program to display Fibonacci sequence using recursion method.
15. Develop Python program that converts decimal to binary, decimal to octal and decimal
to hexadecimal number using user defined function.
16. Develop Python program to find maximum, minimum and average of given numbers
using user defined function.
2. Modules in Python
1. What is meant by module in Python? List some built-in modules in Python.
2. Describe with example: Module in Python.
3. Describe Modules in Python.
4. What is meant by module in Python. List some of the built-in modules and built-in
functions of Python.
5. How do you import and use standard and external modules in Python? Explain the
difference between import module, from module import name, and import module as alias.
3. Built-in Functions
1. Explain the use of following built-in functions in Python: max(), pow(), str(), input().
4. File Handling
1. What is the necessity of file operations? Explain different modes of file opening. Which
mode is preferred if…
2. With the help of suitable example explain how we can read and write to a CSV file in
Python.
3. Write a function in Python to count the number of lines from a text file 'sample.txt' which
are not starting with the alphabet 'T'.
4. Write a program to print 100 Fibonacci numbers in file 'Myfibonacci.csv'.
5. Data Visualization (Matplotlib & Plotting)
1. Enlist types of plot available in Python matplotlib module.
2. Write a program to plot:
- sine wave
- cosine wave
- y = x^2 + 2x + 1 in range -5 to 5 on (A) separate plots and (B) same plot. Put axes labels and
plot title for both plots.
3. Write a Python program to find roots of quadratic equation y = 3x^2 - 5x - 4 in range -5 to 5
and plot it. Put axes labels and plot title.
4. Develop Python program that creates a matrix graph of the following plots using subplot:
1. Linear plot
2. Scatter plot
3. Histogram
4. Bar chart
Chapter 4
1. File Handling Basics
1. Describe file handling functions in Python.
2. Which method is used to read the contents of a file which is already created?
3. Explain all file processing modes supported in Python.
4. Explain different mode for opening a file in Python.
5. Enlist mode of file in Python.
6. Enlist all file processing modes supported in Python.
7. Describe how to read from and write to a text file in Python. What functions and methods
are commonly used for these operations?
8. What are the different file modes in Python, such as 'r', 'w', 'a', and 'b'? Describe each
mode and its typical use case.
2. CSV File Handling
1. Explain the different methods available for manipulating the CSV files in Python.
2. Develop Python program to create CSV file that contains five entries along with header
(serial number, name, birth_date, and city).
3. Write a Python program to read marks of students from 'student_marks.csv'. Find
average, maximum, and minimum marks from data. (File contains 100 records)
4. Write a Python program to read data from 'file1.csv', if data is negative write it in
'negative.csv' and if data is positive write it in 'positive.csv'.
3. File Handling Programs
1. Write a program to print the same Python program using file handling.
2. Develop Python program that reads and prints first n lines from an existing file and also
creates a new file that has the first n lines from the existing file.
4. Exception Handling
1. Describe exception handling with example.
2. What is an exception? Explain about the different types of exceptions in Python.
3. Explain file exception handling. What are the reasons for file exceptions?
4. Explain catching exception using try and except in Python.
5. Describe the need for catching exceptions using try and except statements with suitable
example.
5. Miscellaneous
1. Explain command line arguments with help of one example.
2. Explain various features of a plot in Python.
Chapter 5
1. Introduction to MicroPython
1. What is MicroPython? Where is it used?
2. Define MicroPython, explain features of MicroPython.
3. Describe features of MicroPython.
4. What is MicroPython? Discuss unique features of MicroPython.
5. Describe features of Python which are not supported by MicroPython.
6. Explain the significance of MicroPython in the context of embedded systems and IoT
(Internet of Things). What advantages does it offer for developing applications on
microcontrollers?
2. Comparison: Python vs MicroPython
1. Differentiate: Python and MicroPython.
2. Explain difference between Python and MicroPython.
3. Explain the difference between Python and MicroPython.
4. Give difference between MicroPython and Python.
5. What are the key differences between MicroPython and standard Python? Discuss aspects
such as memory usage, performance, and supported features.
6. Describe merits and demerits of MicroPython over Python.
3. MicroPython Development Tools
1. Enlist various IDE available to program MicroPython.
2. List Integrated Development Environments (IDE) used for MicroPython programming.
3. Enlist various tools available to program MicroPython.
4. Enlist various IDE available to carry out programming in MicroPython.
5. List different features available in NodeMCU 8266 controller.
4. MicroPython Programming Tasks
1. Write MicroPython program to blink LED at 1 sec on GPIO pin.
2. Write MicroPython program to read proximity sensor connected at Pin1, blink the LED if
sensing is detected.
3. Write program in MicroPython to send digital data on GPIO pins of NodeMCU and glow
LED connected with NodeMCU or any other MicroPython supported board.
4. Write MicroPython program to send digital data 0 to pin no. 4 and digital data 1 to pin no.
2 of NodeMCU board.
5. Write MicroPython program to read sensor data from pin A0 of NodeMCU board. Glow
LED connected at pin number 4 of NodeMCU if sensor data is greater than 500.
6. Write a short note on: Sensor programming using MicroPython.
7. Write a Python program to turn on and off LED when the button is pressed. Button and
LED are connected to GPIO pin.
8. Sketch circuit diagram to interface 8 LEDs with GPIO of CPU*; write MicroPython
program to blink LEDs in ring counter pattern.
9. Sketch circuit diagram to interface 16x2 LCD with CPU*; write MicroPython program to
display 'Python Programming' on first line of LCD.
10. Develop program in MicroPython to send digital data on GPIO pin of MicroPython
supported board and blink LED connected to it.