Syllabus
Unit 1
Review of programing in Python: Data types, strings, arrays, lists, conditionals, loops and iterative operations, functions, scope; Plotting using matplotlib. Error handling, basic file operations. Writing programs in multiple scripts, debugging the code with print statements or assertions; Remarks on floating point arithmetic. [2 weeks]
Sample applications (lab exercises) [2 weeks]
- Basic programming practice. Working with arrays:
- Linear interpolation of data sets; other built-in interpolation functions.
Unit 2
Array and list operations, tuples, object id and references, passing arrays by reference; sets, dictionaries; Introduction to NumPy and SciPy. Random number generators and demonstrations of simulation of probability distributions. [3 weeks]
Sample Applications (lab exercises): [2 weeks]
3. Finding roots: Newton-Raphson and bisection methods.
4. Statistical experiments like coin toss or dice problems; generating statistical samples from distributions like binomial, normal distributions, binned frequency table and histogram, estimation of statistical parameters for finite samples.
Units 3-4
Classes and OOP: definition, attributes, methods, instances, accessor and mutator methods; function classes for mathematical computations, static methods and attributes. Inheritance: generalization and specialization; Polymorphism, class hierarchies, subclasses. [4 weeks]
Sample applications and demonstrations: [5 weeks]
5. Vector and complex number classes; operator overloading.
6. Numerical Differentiation of simple functions; Numerical Integration using Trapezoid or Simpsons’ rule.
7. Solving set of first order ordinary differential equations using a Runge-Kutta method – projectile motion, simple harmonic oscillator, planetary motion; SciPy integrators;
Particle class for particle dynamics with methods to modify its position, velocity, solving for trajectory of particle using particle class supplying forces and initial conditions.
Unit 5
Recursion; Sorting and searching, and introduction to algorithmic complexity – time and memory complexity; Linear least squares fitting. [2 weeks]
Sample applications and demonstrations: [2 weeks]
8. Factorials, Fibonacci series, Euclid’s algorithm for GCD calculation.
9. Sorting randomly ordered eigenvalue-eigenvector pairs in the increasing order of eigenvalues, searching for eigenvector for a given eigenvalue or equivalent examples.
Further applications (if time permits):
10. Sample application for arrays – images. Sample exercises: I/O operations with images; data structure of images, RGB pixel arrays, extracting R, G, and B arrays, grayscale images, flipping and cropping images (slicing image arrays). [1 week]
A term project may be given during the last third of the semester, carried out in groups of two to four students.
Course Objectives and Outcomes
Course Outcomes: On successful completion, students will be able to
CO1: Understand programming language syntax and its definition by example of Python.
CO2: Adequately use standard programming constructs: branching, selection, repetition, functions, composition, modules, aggregated data (arrays, lists, etc.)
CO3: Identify and debug coding errors in a python program
CO4: Understand the concepts of error handling, basic file operations, sets, dictionaries.
CO5: Use programing as a tool to understand probability concepts; understand and fit a straight line to a linear data set, perform numerical differentiation and integration, integrate simple differential equations, solve for eigenvalues and eigenvectors, sort and search them.
Evaluation Pattern: As in the rules for Assessment Procedure (R.14)
Textbooks/ References
- Tony Gaddis, Starting Out with Python, 3E, Pearson, 2015.Book contains flowcharting and pedagogical program development in an introductory Python book. Ch. 1 to 5, Ch 7.
- Hans Petter Langtangen, A Primer on Scientific Programming with Python, 5E, Springer, 2016. Ch. 1 to 3, Ch. 4 (carefully selected material appropriate for first year students)
- Christian Hill, Learning Scientific Programming with Python, 2016(carefully selected material appropriate for first year students)
- David J. Pine, Introduction to Python for Science and Engineering (2019, CRC Press)
- Peter R. Turner, Thomas Arildsen, Kathleen Kavanagh, Applied Scientific Computing with Python (2018, Springer) (SciPy interpolation functions, integrators)
- Zed A Shaw, Learn Python the Hard Way, 3E, Pearson, 2017
- Mahendra Verma, Practical Numerical Computing Using Python: Scientific & Engineering Applications, Self-Published
- One material and tutorials: www.python.org; https://www.learnpython.org; www.vpython.org; https://www.pythonlikeyoumeanit.com.
Skills and Employability: Entire course contents with tutorials and assignments help build foundations and develops computational thinking, programming skills – design and implementation of software for scientific, engineering and industrial computing applications in universities, industries and research labs/organizations.