Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Lec 1, Introduction To Python PDF

This document outlines a computer programming course at the University of Calcutta. The course will cover Visual Basic .NET for GUI development, Python programming fundamentals, and applying Python libraries for hardware and software system development. It is divided into four modules covering Visual Basic, Visual Basic programming, Python libraries, and Python programming. The course aims to teach students windows programming, data handling, interfacing with hardware, and machine learning applications.

Uploaded by

Akash Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Lec 1, Introduction To Python PDF

This document outlines a computer programming course at the University of Calcutta. The course will cover Visual Basic .NET for GUI development, Python programming fundamentals, and applying Python libraries for hardware and software system development. It is divided into four modules covering Visual Basic, Visual Basic programming, Python libraries, and Python programming. The course aims to teach students windows programming, data handling, interfacing with hardware, and machine learning applications.

Uploaded by

Akash Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

COMPUTER PROGRAMMING

PCC-EE 602
Shri Nirmal Murmu
Department of Applied Physics
University of Calcutta
Course Outcomes
• At the end of this course, students will be able to learn about

• CO1: Understanding of windows environment using VB .Net


• CO2: Design and development of GUI in windows with custom made
requirements.
• CO3: The fundamentals of Python programming.
• CO4: Application of various Python libraries for customised hardware
and software based system developments.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Syllabus
• Module 1: Introduction to Visual basic (8 hour)
• Fundamentals of GUI development using VB.Net, Concepts of object, method and event in VB.Net,
Utilisation of various tools, Components and References, basic concept of event handling, I/O File
handling and data handling.
• Module 2: Visual basic Programming (10 hour)
• Learn to develop program in windows environment, simple display program, Key board and
mouse interactive program, Reading and writing I/O files, handling of other windows program -
like reading and writing Excel file, Excel plotting, interfacing of USB/COM ports, development of
net based application in client/server mode.
• Module 3: Introduction to Python libraries (10 hour)
• Python Types, Expressions, Strings, Lists, Tuples, Python memory model (names, mutable and
immutable values), List operations, Regular Expressions, Python Functions, Abstract Data types,
Classes and Objects in Python, Exception handling, Handling files, Python
Scientific/Statistical/Machine Learning Libraries.
• Module 4: Python programming (12 hour)
• Python Programming: Object based program using multi threading, I/O handling of files, Printing
and display using timer operation, program for handling of interfacing of cameras, program to
develop machine learning based applications.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
References

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Objective of The Session
• Importance of Python
• Basics of Python
• Installation
• First step to Python programming

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Python’s Benevolent Dictator For Life

“Python is an experiment in how


much freedom programmers need.
Too much freedom and nobody
can read another's code; too little
and expressiveness is
endangered.”
- Guido van Rossum

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
History
• Started by Guido Van Rossum
as a hobby
• Now widely spread
• Open Source! Free!
• Versatile

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Development

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Brief History of Python
• Invented in the Netherlands, early 90s by Guido van
Rossum
• Named after Monty Python
• Open sourced from the beginning
• Considered a scripting language, but is much more
• Scalable, object oriented and functional from the
beginning
• Used by Google from the beginning
• Increasingly popular
DEPARTMENT OF APPLIED PHYSICS,
EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Python Today
• Developed a large and active scientific computing and data
analysis community
• Now one of the most important languages for
• Data science
• Machine learning
• General software development
• Packages: NumPy, pandas, matplotlib, SciPy, scikit-learn,
statsmodels

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
What is Python
• Python is a general purpose, high level, interpreted
language with easy syntax and dynamic semantics.

❖ Guido van Rossum, the creator of the Python language, named the language after the BBC show
"Monty Python's Flying Circus". He doesn't particularly like snakes that kill animals for food by
winding their long bodies around them and crushing them.
DEPARTMENT OF APPLIED PHYSICS,
EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Popularity of Python

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Modes
1. IPython
• Python from the command line with no script (no arguments), gives
an interactive prompt. This facility for learning Python and for trying
small snippets of code.
• Interactive shell that is built with python
• Python can be run interactively by adding features like syntax
highlighting, code completion etc

2. Python scripts
• What if we want to run more than a few lines of code?
• Then we must write text files in .py
DEPARTMENT OF APPLIED PHYSICS,
EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Simple
• Python is a simple and minimalistic language. Reading a good
Python program feels almost like reading English, although very
strict English!
• Allows to concentrate on the solution to the problem rather than
the language itself.
• Easy to Learn
• Has an extraordinarily simple syntax, as already mentioned.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Free and Open Source
• Python is an example of a FLOSS (Free and Open Source
Software).
• Freely distribute copies of this software,
• read its source code, make changes to it, and use pieces of it in new
free programs.
• This is one of the reasons why Python is so good - it has
been created and is constantly improved by a community
who just want to see a better Python.
• High-level Language
• Never need to bother about the low-level details such as
managing the memory used by your program, etc.
DEPARTMENT OF APPLIED PHYSICS,
EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Portable
• Python has been ported to (i.e. changed to make it work on) many platforms.
• If you are careful enough to avoid any system-dependent features, can use
Python on Linux, Windows, FreeBSD, Macintosh, etc.
• Extensible
• Can code a part of a program in C or C++ and then use it from the Python
program
• Embeddable
• Can embed Python within the C/C++ programs to give 'scripting' capabilities for
the program's users.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Portable
• Python has been ported to (i.e. changed to make it work on) many platforms.
• If you are careful enough to avoid any system-dependent features, can use
Python on Linux, Windows, FreeBSD, Macintosh, etc.
• Extensible
• Can code a part of a program in C or C++ and then use it from the Python
program
• Embeddable
• Can embed Python within the C/C++ programs to give 'scripting' capabilities for
the program's users.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Interpreted
• A program written in a language like C or C++ is converted into a machine
language using a compiler with various flags and options.
• When you run the program, the linker/loader software copies the program from
hard disk to memory and starts running it.
• Python, on the other hand, does not need compilation to binary.
• Internally, Python converts the source code into an intermediate form called
bytecodes and then translates this into the machine language with the proper
libraries are linked and loaded.
• Extensive Libraries
• The Python Standard Library is huge indeed.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Interpreted
• A program written in a language like C or C++ is converted into a machine
language using a compiler with various flags and options.
• When you run the program, the linker/loader software copies the program from
hard disk to memory and starts running it.
• Python, on the other hand, does not need compilation to binary.
• Internally, Python converts the source code into an intermediate form called
bytecodes and then translates this into the machine language with the proper
libraries are linked and loaded.
• Extensive Libraries
• The Python Standard Library is huge indeed.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Features of Python
• Object Oriented
• Python supports procedure-oriented programming as well as object-oriented
programming.
• In procedure-oriented languages, the program is built around procedures or
functions which are nothing but reusable pieces of programs.
• In object-oriented languages, the program is built around objects which
combine data and functionality.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
What is an Object?
Real-world objects have attributes and behaviors.

Examples:
• Dog
• Attributes: breed, color, hungry, tired, etc.
• Behaviors: eating, sleeping, etc.
• Bank Account
• Attributes: account number, owner, balance
• Behaviors: withdraw, deposit

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Classes
➢The definitions of the attributes and methods of an object are organized into
a class. Thus, a class is the generic definition for a set of similar objects (i.e.
Person as a generic definition for Jane, Mitch and Sue)

• A class can be thought of as a template used to create a set of objects.


• A class is a static definition; a piece of code written in a programming
language.
• One or more objects described by the class are instantiated at runtime.
• The objects are called instances of the class.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Classes - Cont’d
• Each instance will have its own distinct set of attributes.
• Every instance of the same class will have the same set of
attributes;
• every object has the same attributes but,
• each instance will have its own distinct values for those attributes.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Object Oriented Programming

• Over time, data abstraction has become essential as programs


became complicated.
• Benefits:
1. Reduce conceptual load (minimum detail).
2. Fault containment.
3. Independent program components.
(difficult in practice).

• Code reuse possible by extending and refining abstractions.


DEPARTMENT OF APPLIED PHYSICS,
EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Object Oriented Programming
• A methodology of programming
• Four (or Five ) major principles:
1. Data abstraction
2. Encapsulation
• Some methods or state variables remain hidden inside the class not accessible
outside it.
3. Information Hiding
4. Polymorphism (dynamic binding)
• The mechanism of decoupling the behavior from the message
• The same message sent to different types of objects results in:
• execution of behavior that is specific to the object and,
• possibly different behavior than that of other objects receiving the same message.
5. Inheritance
• A new class a subclass is that it will inherit attributes and methods of its parent
class

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Python Interpreter
• An interpreter is a computer program that directly executes,
i.e. performs, instructions written in a programming or
scripting language, without requiring them previously to
have been compiled into a machine language program. So
unlike Java, Python uses an interpreter.
• The interpreter is a program that we need to run our python
code or scripts. It basically provides an interface between
the code and the computer hardware to get the results of
the code.

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA
Python Version
• Python 2.x
• Python 3.x
• Sometimes referred to as Python 3000 or Py3K
• In the new version of Python is to remove all the small problems
and nit-picks that have accumulated over the years and to make
the language even more clean
• There is a utility to assist to convert 2.x to 3.x source

Documentation: http:/ / docs. python. org/ .

DEPARTMENT OF APPLIED PHYSICS,


EVEN SEMESTER
UNIVERSITY OF CALCUTTA

You might also like