Course File Python
Course File Python
BHOPAL
COURSE-FILE
Python CSE AL-306
Issued by:
Prepared by: Approved By:
M2. To Practice and nurture high standards of human values, transparency and accountability.
M3. To collaborate with other academic and research institutes as well as industries in order to
strengthen education and research.
M4. To uphold skill development for employability and entrepreneurship for interdisciplinary
research and innovations.
To be a centre of excellence for providing quality technical education to develop future leaders
with the aspects of research &computing, Software product development and entrepreneurship.
M2: To conduct research and development activities in contemporary and emerging areas of
computer science & engineering.
M3: To inculcate moral values & entrepreneurial skills to produce professionals capable of
providing socially relevant and sustainable solutions.
Academic Calendar
Marks Policy
Attendance
Teacher Marks Total
Marks
Quiz Assignment Marks 5 5 10
Teacher Assessment
Attendance Marks Total
Marks
Lab Work/sessional Marks 15 5 20
Lab Work/sessional Marks (Language
10 10 20
Lab)
Practical Slot (10 + 10 Marks) for Workshop Practices/ Swachh Bharat Summer Internship Unnat Bharat
Abhiyan / Rural Outreach /Internship-I/II/III
Lab Work ( As-
Teacher Assess-
Attendance Marks signment /Quiz Total
ment Marks
etc.)
Lab Work Marks 5 NIL 5 10
Assignment Quiz /Term work Marks 5 5 NIL 10
Swachh Bharat Summer Internship Unnat 5
5 NIL 10
Bharat Abhiyan / Rural Outreach (MATHEMATICS)
Internship-I/BT107 40 MINIMUM
(as per I year internship 10 RANGE (30 TO 50
training) 50 )
Attendance Mark Distribution
(For MIDSEM/Quiz Assignment/Lab Work & Sessional Marks etc. )
% Attendance Marks Marks
(Theory + Practical) (Max 5 marks) (Max 10 marks)
75% and above 5 10
60-74% 4 8
50-59% 3 6
40-49% 2 4
Below 40% 1 2
Learning, III-Semester
Variable and Basic data types,String, Escape Sequences, Operators and Expressions,
Module2: Data Structure: List, Tuples, Dictionary, DataFrame and Sets, constructing,
Statement - For, While, Nested Loops. Control statements - Break, Continue, Pass.
Exception Handling, Except clause, Try finally clause, User Defined Exceptions.
Module5: Modules and Packages: Standard Libraries: File I/0, Sys, logging, Regular
References
List of Experiments:
Method.
13. To write a Python program to find the most frequent words in a text read from a
file.
Rational
Unit 1
Python is a high-level, interpreted programming language known for its simplicity and readability. It was created by
Guido van Rossum and first released in 1991. Python emphasizes code readability and has a clean and easy-to-learn syn-
tax, which makes it an excellent language for beginners and professionals alike.
Variables in Python are dynamically typed, meaning you don't have to declare the type explicitly. You can assign any
value to a variableStrings and Escape Sequences:
Strings in Python are enclosed in either single (') or double (") quotes. Escape sequences are used to represent special
characters within strings, such as newline (\n), tab (\t), and backslash (\\).
Python supports various operators, including arithmetic operators (+, -, *, /, %), comparison operators (==, !=, <, >, <=,
>=), logical operators (and, or, not), and more.
Indentation:
Indentation is crucial in Python to define blocks of code, such as within loops, conditional statements, and function def-
initions. Consistent indentation using spaces or tabs is required, and mixing them can result in errors.
Input Output:
You can take input from the user using the input() function and display output using the print() function.
Functions:
Functions are defined using the def keyword. They allow you to encapsulate reusable pieces of code. Functions can
have parameters and return values.
Comments:
Comments in Python start with the # character and extend to the end of the line. They are used to document code and
improve its readability.
Unit 2
Lists:A list is a mutable, ordered collection of items. Lists are defined using square brackets [] and can contain
elements of different data types. You can modify, add, and remove elements from a
Tuples:A tuple is an immutable, ordered collection of items. Tuples are defined using parentheses () and, like lists, can
contain elements of different data types. However, once a tuple is created, you cannot modify its elements.
Dictionary:A dictionary is an unordered collection of items, consisting of key-value pairs. Dictionaries are defined us-
ing curly braces {} and key-value pairs are separated by colons :.
Sets:
A set is an unordered collection of unique elements. Sets are defined using curly braces {} but without key-value pairs.
You can create a set from a list using the set() function.
Unit 3
Conditional Statements:
Conditional statements in Python allow you to execute different blocks of code based on the evaluation of certain con-
ditions.
If Statement:
The if statement is used to execute a block of code if a condition is true.
x = 10
if x > 5:
print("x is greater than 5")
If-else Statement:
The if-else statement allows you to execute one block of code if the condition is true and another block if the condition
is false.
x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is not greater than 5")
Iterative statements allow you to execute a block of code repeatedly.
For Loop:
The for loop is used to iterate over a sequence (such as a list, tuple, or string) or any iterable object.
python
Copy code
for i in range(5):
print(i)
While Loop:
The while loop is used to execute a block of code as long as the condition is true.
x=0
while x < 5:
print(x)
x += 1
Nested Loops:
You can nest loops within each other to perform more complex iterations.
python
Copy code
for i in range(3):
for j in range(3):
print(i, j)
Control Statements:
Control statements allow you to alter the flow of execution within loops or conditional statements.
Break Statement:
The break statement is used to exit the loop prematurely.
for i in range(5):
if i == 3:
break
print(i)
Continue Statement:
The continue statement is used to skip the current iteration and proceed to the next iteration of the loop.
for i in range(5):
if i == 3:
continue
print(i)
Pass Statement:The pass statement is a null operation, meaning it does nothing. It can be used as a place-
holder when a statement is syntactically required but you don't want any code to execute.
x = 10
if x > 5:
pass # Do nothing for now
else:
print("x is not greater than 5")
Unit 4:Class and Object:
A class is a blueprint for creating objects. It defines the attributes and behaviors that objects of the class will
have.
An object is an instance of a class. It represents a specific entity with its own unique state and behavior.
class MyClass:
pass
obj = MyClass() # Creating an object of MyClass
Attributes:
Attributes are the properties or characteristics associated with a class or object. They can be variables (data
attributes) or functions (methods).
class Person:
def __init__(self, name, age):
self.name = name # Data attribute
self.age = age # Data attribute
person1 = Person("Alice", 30)
print(person1.name) # Accessing data attribute
Methods:
Methods are functions defined within a class. They define the behavior of objects of the class.
Methods can operate on the object's attributes and modify their state.
class Circle:
self.radius = radius
Overriding occurs when a subclass provides a specific implementation of a method that is already
defined in its superclass.
Data Hiding:
Data hiding (encapsulation) is the process of restricting access to certain attributes or methods of a class.
It helps to prevent accidental modification of data and ensures that access to attributes and methods is
controlled.
Unit 5
Exception handling is a crucial aspect of programming to deal with unexpected errors or exceptional situations. Python
provides several constructs for exception handling:
Try-Except Clause:
The try-except block allows you to handle exceptions gracefully by catching and responding to specific types of errors.
try:
x = 10 / 0 # This will raise a ZeroDivisionError
except ZeroDivisionError:
print("Division by zero is not allowed")
Try-Finally Clause:
The try-finally block ensures that certain code (usually cleanup code) runs regardless of whether an exception
try:
file = open("example.txt", "r")
# Perform some operations with the file
finally:
file.close() # This will always execute, even if an exception occurs
User Defined Exceptions:
You can create custom exception classes by subclassing built-in exception classes or the Exception class.
Blooms Taxonomy
PSO2: An ability to develop programming skills using modern software tools and techniques.
PSO3: An ability to develop real time projects for problem solving of domains such as Machine
PSO2 An ability to develop programming skills using modern software tools and techniques.
An ability to develop real time projects for problem solving of domains such as Machine learning Cyber
PSO3
security, block chain and big data.
An ability to grab research, higher studies and entrepreneurship opportunities towards society with moral
PSO4
values and ethics.
CO/PSO Matrix
CO/PSO PSO1 PSO2 PSO3 PSO4
CO406.1 - 2 3 3
CO406.2 - 2 3 3
CO406.3 - 2 3 3
CO406.4 - 2 3 3
CO406.5 - 3 3 3
- 2.2 3 3
CSE AL-306
List of Experiment
*
**
***
****
*****
****
***
DEPARTMENT OF CSE AIML
Page 21
LAKSHMI NARAIAN COLLEGE OF TECHNOLOGY EXCELLENCE, BHOPAL
**
*
CO3
a. Write a Python program to solve the
Fibonacci sequence using recursion.
Lab-6
b. Write a Python program to get the sum of a
non-negative integer using recursion.
Lab-11 CO4
CO5
a. Write a Python program to read each row
from a given csv file and print a list of strings.
Practical Per- Either the stu- The student The student The student per- The student per-
formance/ dent is Absent performed al- performed al- formed 75 % of formed 100 %
in all lab ses- most 25 most 50 practical suc- of practical suc-
Teacher’s
sions or per- % of % of cessfully. cessfully.
Assessment
formed less practi- practi-
(10)
than 25% of cal suc- cal suc-
practical or the cess- cess-
performance fully. fully.
was
not successful.
Practical Either the stu- The student’s The student’s The student’s The student’s
Quiz/Assign- dent is Absent score is be- score is be- score is be- score is greater
ment (5) or the response tween 01 to 25 tween 26 to 50 tween 51 to 75 than 75 %.
is not avail- %. %. %.
able/
incomplete.
Attendance (5) Student’s atten- Student’s at- Student’s at- Student’s at- Student’s at-
dance is below tendance is be- tendance is be- tendance is be- tendance is
40 %. tween 40 % tween 50 % tween 60 % 75% and
and and and above.
50 %. 59 %. 74 %.
End Semester Grade F repre- Grade D rep- Grade C + rep- Grade B + rep- Grade A + rep-
Examination sents marks be- resents marks resents marks resents marks resents marks
(100) tween 30 - 0 between 31-40 between 51-60 between 71-80 between 91-
and perfor- and perfor- and perfor- and perfor- 100 and perfor-
Grade mance is Fail mance is Mar- mance is Aver- mance is Very mance is Out-
%Marks Grade I repre- ginal age Good standing
range (based sents Incom-
on absolute plete. Grade C rep- Grade B repre- Grade A repre-
marks system) resents marks sents marks be- sents marks be-
Grade W repre-
Description of between 41-50 tween 61-70 and tween 81-90
sents With-
performance) and perfor- performance is performance is
drawal
mance is Excellent
Satisfactory Good