0% found this document useful (0 votes)
4 views18 pages

PythonProgramming Unit 1

Python is an open-source, object-oriented programming language developed by Guido van Rossum in the early 1990s. It has evolved through various versions, starting from its inception in the late 1980s, with significant updates like Python 3.0 released in 2008, and is known for its simplicity, versatility, and extensive libraries for applications in web development, data science, artificial intelligence, and more.

Uploaded by

sudhakar945
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views18 pages

PythonProgramming Unit 1

Python is an open-source, object-oriented programming language developed by Guido van Rossum in the early 1990s. It has evolved through various versions, starting from its inception in the late 1980s, with significant updates like Python 3.0 released in 2008, and is known for its simplicity, versatility, and extensive libraries for applications in web development, data science, artificial intelligence, and more.

Uploaded by

sudhakar945
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Q)Python History and Versions?

o Python laid its foundation in the late 1980s.


o The implementation of Python was started in December 1989 by Guido Van
Rossum at CWI in Netherland.
o In February 1991, Guido Van Rossum published the code (labeled version 0.9.0)
to alt.sources.
o In 1994, Python 1.0 was released with new features like lambda, map, filter, and
reduce.
o Python 2.0 added new features such as list comprehensions, garbage collection
systems.
o On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was
designed to rectify the fundamental flaw of the language.
o ABC programming language is said to be the predecessor of Python language,
which was capable of Exception Handling and interfacing with the Amoeba
Operating System.
o The following programming languages influence Python:
o ABC language.
o Modula-3

…………………… end……………….
Q)indentation?

Indentation refers to the spaces at the beginning of a code line.

Where in other programming languages the indentation in code is for readability only,
the indentation in Python is very important.

Python uses indentation to indicate a block of code.


…………………….. end ………………
Q)Python Features?

Python provides many useful features which make it popular and valuable from the
other programming languages. It supports object-oriented programming, procedural
programming approaches and provides dynamic memory allocation. We have listed
below a few essential features.

1) Easy to Learn and Use

Python is easy to learn as compared to other programming languages. Its syntax is


straightforward and much the same as the English language. There is no use of the
semicolon or curly-bracket, the indentation defines the code block. It is the
recommended programming language for beginners.
2) Expressive Language

Python can perform complex tasks using a few lines of code. A simple example, the
hello world program you simply type print("Hello World"). It will take only one line to
execute, while Java or C takes multiple lines.

3) Interpreted Language

Python is an interpreted language; it means the Python program is executed one line
at a time. The advantage of being interpreted language, it makes debugging easy and
portable.

4) Cross-platform Language

Python can run equally on different platforms such as Windows, Linux, UNIX, and
Macintosh, etc. So, we can say that Python is a portable language. It enables
programmers to develop the software for several competing platforms by writing a
program only once.

5) Free and Open Source

Python is freely available for everyone. It is freely available on its official


website www.python.org. It has a large community across the world that is
dedicatedly working towards make new python modules and functions. Anyone can
contribute to the Python community. The open-source means, "Anyone can download
its source code without paying any penny."

6) Object-Oriented Language

Python supports object-oriented language and concepts of classes and objects come
into existence. It supports inheritance, polymorphism, and encapsulation, etc. The
object-oriented procedure helps to programmer to write reusable code and develop
applications in less code.

7) Extensible

It implies that other languages such as C/C++ can be used to compile the code and thus
it can be used further in our Python code. It converts the program into byte code, and
any platform can use that byte code.
8) Large Standard Library

It provides a vast range of libraries for the various fields such as machine learning,
web developer, and also for the scripting. There are various machine learning
libraries, such as Tensor flow, Pandas, Numpy, Keras, and Pytorch, etc. Django, flask,
pyramids are the popular framework for Python web development.

9) GUI Programming Support

Graphical User Interface is used for the developing Desktop application. PyQT5,
Tkinter, Kivy are the libraries which are used for developing the web application.

10) Integrated

It can be easily integrated with languages like C, C++, and JAVA, etc. Python runs code
line by line like C,C++ Java. It makes easy to debug the code.

11. Embeddable

The code of the other programming language can use in the Python source code. We
can use Python source code in another programming language as well. It can embed
other language into our code.

12. Dynamic Memory Allocation

In Python, we don't need to specify the data-type of the variable. When we assign some
value to the variable, it automatically allocates the memory to the variable at run time.
Suppose we are assigned integer value 15 to x, then we don't need to write int x =
15. Just write x = 15.

…………………….. end…………….
Q)python applications?

1. Web and Internet Development


Python lets you develop a web application without too much trouble. It has libraries for
internet protocols like HTML and XML, JSON, e-mail processing, FTP, IMAP, and easy-to-use
socket interface. Yet, the package index has more libraries:

 Requests – An HTTP client library


 BeautifulSoup – An HTML parser
 Feedparser – For parsing RSS/Atom feeds
 Paramiko – For implementing the SSH2 protocol
 Twisted Python – For asynchronous network programming
We also have a gamut of frameworks available. Some of these are- Django, Pyramid. We also
get microframeworks like flask and bottle. We’ve discussed these in our write-up on
an Introduction to Python Programming. We can also write CGI scripts, and we get
advanced content management systems like Plone and Django CMS.
2. Desktop GUI Applications
Most binary distributions of Python ship with Tk, a standard GUI library. It lets you draft a
user interface for an application. Apart from that, some toolkits are available:

 wxWidgets
 Kivy – for writing multitouch applications
 Qt via pyqt or pyside
And then we have some platform-specific toolkits:

 GTK+
 Microsoft Foundation Classes through the win32 extensions
 Delphi
3. Science and Numeric Applications
This is one of the widespread applications of Python programming. With its power, it comes
as no surprise that Python finds its place in the scientific community. For this, we have:

 SciPy – A collection of packages for mathematics, science, and engineering.


 Pandas– A data-analysis and -modeling library
 IPython – A powerful shell for easy editing and recording of work sessions. It also
supports visualizations and parallel computing.
 Also, NumPy enables us to deal with complex numerical calculations.
4. Software Development
Software developers make use of Python as a support language. They use it for build-control
and management, testing, and for a lot of other things:

 SCons – for build-control


 Buildbot, Apache Gump – for automated and continuous compilation and testing
 Roundup, Trac – for project management and bug-tracking.
 The roster of Integrated Development Environments
5. Education
Thanks to its simplicity, brevity, and large community, Python makes for a great
introductory programming language. Applications of Python programming in education has
a huge scope as it is a great language to teach in schools or even learn on your own.
6. Business
Python is also a great choice to develop ERP and e-commerce systems:
 Tryton – A three-tier, high-level, general-purpose application platform.
 Odoo – A management software with a range of business applications. With that, it’s
an all-rounder and forms a complete suite of enterprise-management applications in-
effect.
7. Database Access
With Python, you have:

 Custom and ODBC interfaces to MySQL, Oracle, PostgreSQL, MS SQL Server, and others.
These are freely available for download.
 Object databases like Durus and ZODB
 Standard Database API
8. Network Programming
With all those possibilities, how would Python slack in network programming? It does
provide support for lower-level network programming:

 Twisted Python – A framework for asynchronous network programming. We


mentioned it in section 2.
 An easy-to-use socket interface
9. Games and 3D Graphics
Safe to say, this one is the most interesting. When people hear someone say they’re
learning Python, the first thing they get asked is – ‘So, did you make a game yet?’
PyGame, PyKyra are two frameworks for game development with Python. Apart from this,
we also get a variety of 3D-rendering libraries.

If you’re one of those game-developers, you can check out PyWeek, a semi-annual game
programming contest.

10. Artificial Intelligence and Machine Learning


The IT industry went far beyond science fiction ideas, and our future is moving towards
Artificial Intelligence. People are keen to move to technologies where machines can mimic
human behaviors, and machines are automating most of the human work. There is also a
need to process and analyze huge volumes of data.

Statistically speaking that Python is the most popular language for Artificial intelligence and
Machine Learning.

The several libraries and frameworks for Artificial intelligence are listed below.
 Tensorflow
 Scikit-learn
 NLTK
 Caffee
 PyTorch
 Keras
 Pandas
 Accord.NET
……………………. End……………
Q)variables?

Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, carname,
total_volume). Rules for Python variables:

 A variable name must start with a letter or the underscore character


 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9,
and _ )
 Variable names are case-sensitive (age, Age and AGE are three different variables)

Example
myvar = "John"

my_var = "John"

_my_var = "John"

print(myvar)

print(my_var)

print(_my_var)

output:
Python Variables - Assign Multiple Values
Python allows you to assign values to multiple variables in one line:

Global Variables

These are those which are defined outside any function and which are accessible
throughout the program, i.e., inside and outside of every function
Example:
a=20
def display():
print(“inside:”,a)
display()
print(“outside:”,a)
output:
inside:20
outside:20

Local variables
Local variables are those which are initialized inside a function and belong only to that
particular function. It cannot be accessed anywhere outside the function.
Example:
def display():
a=30
print(a)
display()
output:30
…………………. End …………………….
Q)What is Python?
 Python is an open source, object-oriented, high-level powerful
programming language.
 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 programs are composed of modules
 Modules contain statements
 Statements contain expressions
 Expressions create and process objects

………………………… END…………

Q)input and output?

input() function
In Python, input( ) function is used to accept data as input at run time. The syntax
for input() function is,
Variable = input (“prompt string”)
Where, prompt string in the syntax is a statement or message to the user, to know what
input can be given.
If a prompt string is used, it is displayed on the monitor; the user can provide expected data
from the input device. The input( ) takes whatever is typed from the keyboard and stores
the entered data in the given variable. If prompt string is not given in input( ) no message is
displayed on the screen, thus, the user will not know what is to be typed as input.

Example 1:input( ) with prompt string


>>>city=input (“Enter Your City: ”)
Enter Your City:Madurai
>>>print (“I am from “, city)
I am from Madurai

Example 2:input( ) without prompt string


>>> city=input()
Rajarajan
>>> print (I am from", city)
I am from Rajarajan

Printf( ):

The print() function prints the specified message to the screen, or other standard output
device.

The message can be a string, or any other object, the object will be converted into a string
before written to the screen.

Syntax
print(object(s), sep=separator, end=end, file=file, flush=flush)

Parameter Values

Parameter Description

object(s) Any object, and as many as you like. Will be converted to string
before printed

sep='separator' Optional. Specify how to separate the objects, if there is more


than one. Default is ' '

end='end' Optional. Specify what to print at the end. Default is '\n' (line
feed)

file Optional. An object with a write method. Default is sys.stdout

flush Optional. A Boolean, specifying if the output is flushed (True) or


buffered (False). Default is False

Example:
print("Hello", "how are you", sep="---")
output:
Hello---how are you
……………………… END ………………………..
Q)python keywords?
Keywords in Python are reserved words that can not be used as a variable name, function
name, or any other identifier.
List of all keywords in Python
and as assert break

class continue def del

elif else except False

finally for from global


if import in Is

lambda None nonlocal not

or pass raise return

True try while with

yield

…………………… end………………..
…………………………..END……………………….
……………………… END ………………

You might also like