Python Syllabus - 2024-25
Python Syllabus - 2024-25
01/08/22
FF No.: 654
PYTHON FOR ENGINEERS
Course Code: CS1018
Credits: 2 Teaching Scheme: Theory: 1 Hours / Week
Laboratory: 2 Hours / Week
Section I
Fundamentals of Python: Features of Python, How to Run Python code, Identifiers, Reserved
Keywords, Variables, Comments in Python, Indentation in Python, Input, Output statements.
Operators: Arithmetic Operators, relational Operators, Logical Operators, bitwise operators, other stray
operators, Operator Precedence, Mathematical Functions, Trigonometric Functions, Random Number
Functions, Strings in python: subscript operator, indexing, slicing a string, string methods
Flow Control and Loops: Decision Making: if statement, if…else statement, if..elif ..else statement,
Nested if statement; Loops : while loop , for loop, range() function, continue and break statement, while and
for loop with else statement, pass statement.
Section II
In-built Data Structures in Python: List, Tuple, Set, Dictionary; Mutable and Immutable Objects,
Data Type Conversion, Built-in methods and comprehensions.
Functions: Function Definition, Function Calling, Function Arguments, Anonymous Functions
(Lambda Functions), recursive function, Function with more than one return value, default value to
parameter, keyword parameter.
File Handling: Opening a File, Modes for Opening a File, Attributes of file object, closing a File,
reading from a File, writing to a File, File Methods.
NumPy and Matplotlib: Introduction to NumPy, Arrays, Array indexing, comparison of Array and List
data types, Array math, Broadcasting. Matplotlib -Plot, subplots and images.
List of Practical:
Assignments on Fundamentals of Python
1. Program to Calculate the Area of a circle and triangle
2. Program to Swap Two Variables
3. Program to Generate a Random Number
4. Program to Convert Kilometers to Miles
5. Program to find maximum of two numbers
6. Program to check if a number is even or odd
7. Program to check if a number is positive, negative or 0
8. A school decided to replace the desks in three classrooms. Each desk sits two students. Given the
number of students in each class, print the smallest possible number of desks that can be purchased.
The program should read three integers: the number of students in each of the three classes, a, b and
c respectively. In the first test there are three groups. The first group has 20 students and thus needs
10 desks. The second group has 21 students, so they can get by with no fewer than 11 desks. 11
desks is also enough for the third group of 22 students. So we need 32 desks in total.
9. H hours, M minutes and S seconds are passed since the midnight (0 ≤ H < 12, 0 ≤ M < 60, 0 ≤ S <
60). Determine the angle (in degrees) of the hour hand on the clock face right now.
10. Given integer coordinates of three vertices of a rectangle whose sides are parallel to the coordinate
axes, find the coordinates of the fourth vertex of the rectangle. In the first test the three given
vertices are (1, 4), (1, 6), (7, 4). The fourth vertex is thus (7, 6).
11. There was a set of cards with numbers from 1 to N. One of the card is now lost. Determine the
number on that lost card given the numbers for the remaining cards.
Given a number N, followed by N − 1 integers - representing the numbers on the remaining cards
(distinct integers in the range from 1 to N). Find and print the number on the lost card.
Assignments on Operators
12. Program to find maximum of three numbers
13. Program to check if a year is leap
14. Program to check if a date is valid
15. Program to find the roots of a quadratic equation
16. Given a string. Delete from it all the characters whose indices are divisible by 3.
17. Given a sequence of integer numbers ending with the number 0. Determine the length of the widest
fragment where all the elements are equal to each other.
18. In bowling, the player starts with 10 pins at the far end of a lane. The object is to knock all the pins
down. For this exercise, the number of pins and balls will vary. Given the number of pins N and
then the number of balls K to be rolled, followed by K pairs of numbers (one for each ball rolled),
determine which pins remain standing after all the balls have been rolled. The balls are numbered
from 1 to N (inclusive) for this situation. The subsequent number pairs, one for each K represent
the start to stop (inclusive) positions of the pins that were knocked down with each role. Print a
sequence of N characters, where "I" represents a pin left standing and "." represents a pin knocked
down.
19. A timestamp is three numbers: a number of hours, minutes and seconds. Given two timestamps,
calculate how many seconds is between them. The moment of the first timestamp occurred before
the moment of the second timestamp.
Assignments on Flow Control and Loops
20. Program to display first n numbers
21. Program to calculate factorial of a numbers
22. Program to display numbers in the reverse order
23. Program to check if a number is prime
24. Program to calculate sum and average of first n numbers
25. Program to display first n multiples of a number
26. Program to display first n Fibonacci numbers
27. Program to find the sum of digits of a number
Assignments on In-built Data Structures
28. Program to Create and view elements of a list
29. Program to Create and view elements of a tuple
30. Program to access List Index and Values
31. Program to add two Lists
32. Program to check if a List is Empty or Not
33. Program to Find the Largest Number in a List
34. Program to Find the Second Largest Number in a List
35. Program to Put Even and Odd elements in a List into Two Different Lists
36. Program to Find all Numbers in a Range which are Perfect Squares and Sum of all Digits in the
Number is Less than 10
37. Program to Generate Random Numbers from 1 to 20 and Append Them to the List