You are on page 1of 36

Python

Subject Code : PCC-CS 393


Category: Professional Core course
Subject Name : IT Workshop (SciLab/MATLAB/Python/R)

What is Python?
Why learn python in 2022?
Syllabus:
Introduction
History,Features,Setting up path,Working with Python,Basic Syntax,Variable and Data
Types, Operator
Conditional Statements
If ,If- else,Nested if-else,Looping,For,While,Nested loops
Control Statements
Break, Continue, Pass
String Manipulation
Accessing Strings, Basic Operations, String slices, Function and Methods
Lists
Introduction, Accessing list, Operations, Working with lists, Function and Methods
Tuple
Introduction,Accessing tuples,Operations,Working,Functions and Methods
Syllabus: Continue...
Dictionaries
Introduction, Accessing values in dictionaries, Working with dictionaries,Properties
Functions
Defining a function,Calling a function,Types of functions,Function Arguments,
Anonymous functions,Global and local variables
Modules
Importing module, Math module, Random module, Packages,Composition,
Input-Output
Printing on screen, Reading data from keyboard, Opening and closing file, Reading and
writing files, Functions

Exception Handling
Exception, Exception Handling,Except clause, Try ? finally clause, User Defined
Exceptions
What is Python?

❑ Python is an open source, object-oriented, high-level


powerful programming language.
❑ Python is a general-purpose programming language, which means that, unlike JavaScript, HTML,
and CSS, it can be used in applications beyond web development. Though it’s been around for 30
years, it has recently become one of the most popular programming languages, and its popularity
continues to grow.

❑ Developed by Guido van Rossum in the early 1990s. Named


after Monty Python

❑ Python runs on many Unix variants, on the Mac, and on


Windows 2000 and later.

❑ Available for download from http://www.python.org.


Python Program

Python programs are composed of modules

Modules contain statements

Statements contain expressions

Expressions create and process objects


Features of Python
❑ Open source:
❑ Easy-to-learn:
❑ High-level Language:
❑ Portable:
❑ Python is Interactive :
❑ Interpreted :
❑ Extendable :
❑ Libraries :
❑ Supports :
Features of Python continue......

• Open source: Python is publicly available open source


software, any one can use source code that doesn't cost
anything.
• Easy-to-learn: Popular (scripting/extension) language,
clear and easy syntax, no type declarations, automatic memory
management, high-level data types and operations, design to
read (more English like syntax) and write (shorter code
compared to C, C++, and Java) fast.
Features of Python continue......

• High-level Language:
High-level language (closer to human) refers to the higher
level of concept from machine language (for example
assembly languages). Python is an example of a high-level
language like C, C++, Perl, and Java with low-level
optimization.
• Portable:
High level languages are portable, which means they are able
to run across all major hardware and software platforms with
few or no change in source code. Python is portable and can be
used on Linux, Windows, Macintosh, Solaris, FreeBSD, OS/2,
Amiga, AROS, AS/400 and many more.
Features of Python continue......

• Python is Interactive :
Python has an interactive console where you get a Python
prompt (command line) and interact with the interpreter
directly to write and test your programs. This is useful for
mathematical programming.
• Interpreted : Python programs are interpreted, takes
source code as input, and then compiles (to portable
byte-code) each statement and executes it immediately. No
need to compiling or linking
Features of Python continue......

• Extendable : Python is often referred to as a "glue" language,


meaning that it is capable to work in mixed-language
environment. The Python interpreter is easily extended and can
add a new built-in function or modules written in C/C++/Java
code.

• Libraries : Databases, web services, networking, numerical


packages, graphical user interfaces, 3D graphics, others.

• Supports :Support from online Python community


Python Interpreter

• In interactive mode, type Python programs and the interpreter


displays the result:
• Type python into your terminal's command line
• After a short message, the >>> symbol will appear
• The above symbol signals the start of a Python interpreter's
command line.
• Python interpreter evaluates inputs (For example >>> 4*(6-2)
return 16)
History
• The name Python was selected from "Monty Python's Flying Circus" which
was a British sketch comedy series created by the comedy group Monty
Python and broadcast by the BBC from 1969 to 1974.
• Python was created in the early 1990s by Guido van Rossum at the
National Research Institute for Mathematics and Computer Science in
Netherlands.
• Python was created as a successor of a language called ABC (All Basic
Code) and released publicly in1991. Guido remains Python's principal
author, although it includes many contributions from active user
community.
• Between 1991 and 2001 there are several versions released, current stable
release is 3.2. In 2001 the Python Software Foundation (PSF) was formed,
a non-profit organization created specifically to own Python-related
Intellectual Property. Zope Corporation is a sponsoring member of the PSF.
• All most all Python releases are Open Source.
Why learn python in 2022?
For becoming skilled at all-in-one language, you should begin
learning Python language that has the ability to expand web apps,
data analysis, user interfaces, and much more, and frameworks are
also available for these tasks. Python is utilized by bigger companies
mostly that can evaluate vast data sets, thus this is a huge chance to
learn it and be a Python programmer.
1. Python Is Beginner-Friendly
2. Python Is Versatile
3. Python Developer Roles Are in High Demand
4. Python Boasts a Supportive Community
5. Python Is the Fastest-Growing Programming
Language
Why learn python in 2022?
Most reasons to learn Python Language In 2022?

6. Python’s popularity & high salary


7. Python is simple & easy to learn
8. Python is portable & extensible
What You Can Do With Python:

❖ Python is used in Data Science


❖ Python is used in scripting & automation
❖ Python used with Big Data
❖ Python supports Testing
❖ Computer Graphics in Python
❖ Python used in Artificial Intelligence
❖ Python in Web Development
1. Python’s popularity & high salary
Reasons for being a popular language-Python

● Python is a versatile language when needed for website development.


● Python is considered instrumental in AI and data science
● Python excessively and uninterruptedly used in the Internet of Things
● Python highly recommended when learning to code

Moreover, Industry leaders like

● YouTube
● Amazon
● Google
● Facebook
● IBM
● NASA
● Netflix

make the use of this language.


python in 2020
2. Python is simple & easy to learn

The aspirants looking to learn Python should never assume that


this language is quite tough to learn and use. The fact, it is the
simplest and easy to learn programming language as of having
simple syntax and readability. Even this language is shorter as
opposed to other programming languages like C, C++, etc.

Besides, easy to learn and featured with a simple syntax, the


developers can quickly build a rapport that is not seamless in other
languages. Thus, Python developers treat their coding more
comfortable and even fun.
3. Python is portable & extensible

This programming language is also the best portable language.


For instance: In a case, the users have a python code for
windows, and they want to execute it on a platform like Mac,
Unix, or Linus. They can do it without any amendment. Even
they can run this code on any platform flawlessly and
uninterruptedly.
Also, Python is also an extensible programming language.
The users can write python code into C++ or C language. Even,
they can compile that code in languages like C++ and C.
4. Python is used in Data Science

Why does Python language preferable than other data science tools?
★ Robust and simple to use
★ Scalable
★ Options of Libraries
★ Extensive Visualization and Graphics options
5. Python is used in scripting & automation

Being an open-source scripting language, we can easily automate


anything on Python. A python learner as a beginner can quickly
learn its basics and gradually able to write its scripts to automate
data or stuff available around.
6. Python used with Big Data

It is a destination of robust scientific packages:


Python programming language equips with powerful library
packages that are needed to gratify data science and analytical
needs and also the top priority for big data applications. The
popular libraries used by big data and Python are:
➔ Pandas
➔ SciPy
➔ NumPy
➔ Mlpy
➔ NetworkX
➔ SymPy
7. Python supports Testing

Python is a valuable programming language that supports


testing flawlessly. It is the best choice for test automation said
by Dan Callahan
8. Computer Graphics in Python

The Python Computer Graphics is used in any domain wherein


the users have to deal with 3D data, be it of any sort or kind. Thus
for visualization, Virtual Reality, photorealistic images, or even
games, Python high language is highly used.
It offers the basic functionality needed to write your tools to
process 3D data. For instance, the cgtypes module is used or
required to reveal the fundamental kinds for Computer Graphics
like matrices, cri modules that have the entire RenderMan API to
establish RIB files, and more.
With these modules, it becomes easier to keep a 3D scene in
memory that can manipulate in Python.
9. Python used in Artificial Intelligence
It is highly used in AI (Artificial Intelligence) as opposed to other
programming languages as of the following reasons:

● It is an independent platform, the most preferable and popular


choice to use in the different platforms with the least tweaks
required even in necessary coding.
● It has prebuilt libraries such as Scipy used for advanced computing,
Numpy used in scientific computation, and Pybrain for machine
learning, being the best language used in AI.
● It is highly dynamic, along with having an option to choose
scripting and OOPs approach. Even the users can use IDE itself to
get the required codes. It is also the best choice for developers that
are struggling with different algorithms.
10. Python in Web Development
How does Python helpful for web development?

● Easy Syntax: It was designed with English-like syntax, the


main reason for preferring this language, among others.
Python is the most recommended language for those who had
never tried for any programming language till now.
● Abundant of frameworks: It has plentiful frameworks to
use. The web developers can experience abundant
web-oriented modules that are designed to assist people in
needing functional websites.In the Python web development
criteria, dominating frameworks that users can use are:

➢ Flask , Django,TurboGears, Pyramid, Flask, Bottle, and


CherryPy.
Why you should learn python in
2021
Python is one of those programming languages that has seen tremendous
growth in its demand and popularity within the last 4-5 years. Whether we
talk about the PYPL index, Stack Overflow, or any other platform – the
language is ranking at the top positions among numerous programming
languages. However, many individuals believe that these ranking
changes frequently and there should be some relevant & valid
reasons to learn and get started with Python!
we’ll let you know about 7 such major reasons that will
clear all your concerns regarding why should you learn
Python in 2021.

1. Simplicity is the Key


2. Comes Up with Utmost Flexibility & Extensibility
3. Being Used with Almost Every Trending Tech Domain
● Want to get into Artificial Intelligence and Machine Learning domain?
● Want to become a Data Scientist or Data Engineer?
● Want to make a career in Web Development or Game Development?
we’ll let you know about 7 such major reasons that will
clear all your concerns regarding why should you learn
Python in 2021.

4. Provides You with a Huge Collection of Libraries and Frameworks

Some of the popular Python libraries and frameworks are listed below:

● For Data Science: NumPy, SciPy, Pandas, PyTorch, etc.


● For Machine Learning: Scikit-Learn, PyBrain, PyML, Tensorflow, etc.
● For Artificial Intelligence: NLTK, Keras, OpenCV, etc.
● For Web Development: Django, Pyramid, Flask, etc.
● For Network Programming: Asyncio, Pulsar, Pyzmq, etc.

5. Preferred for Scripting and Automation

6. Backed By Huge Community Support

7. And yes, the Salary of Python Developers is Comparatively Higher!


Working with Python
Topics:
❖ Basic Syntax
❖ Constants ,Variable
❖ Types
❖ expession
❖ Operator
In this lesson you will learn the basics of Python and you will write your first Python program:

○ First python program


i. Comment
ii. Syntactic Error
iii. Semantic error

○ Types and Types-custing


○ Constants ,variables and Expressions
First python Program
A statement or expression is an instruction the computer will run or execute. Perhaps the
simplest program you can write is a print statement. When you run the print statement, Python
will simply display the value in the parentheses. The value in the parentheses is called the
argument.

❖ A Semantic error is when your logic is wrong.For example, if you enter Python 102
instead of Python 101, you don't get an error message,but your code is wrong.
Comment
❖ Comment tells other people what your code does.
❖ Single line comment
You simply put a hash symbol proceeding your comment. When you run the code, Python
will ignore the comment.

❖ Multiline comment
A triple quoted multi-line string is also treated as
comment if it is not a docstring of a function or class.
Syntactic error
❖ A Syntactic error is when Python does not understand your code. For example, if you
spell print "frint", you will get an error message.
Type in Python (int,float,str,bool,...
Type-casting in Python
You can change the type of the expression in Python; this is called type-casting.

You might also like