0% found this document useful (0 votes)
0 views

Unit 1 Python

The document provides an introduction to Python programming, covering its history, features, syntax, and applications. It highlights Python's ease of use, cross-platform capabilities, and extensive libraries, making it suitable for various programming tasks. Additionally, it explains key functions like input and print, as well as typecasting techniques in Python.

Uploaded by

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

Unit 1 Python

The document provides an introduction to Python programming, covering its history, features, syntax, and applications. It highlights Python's ease of use, cross-platform capabilities, and extensive libraries, making it suitable for various programming tasks. Additionally, it explains key functions like input and print, as well as typecasting techniques in Python.

Uploaded by

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

Introduction to Python Programing (UNIT – 1)

Syllabus

Overview of programming Languages; History of Python Language, Features of Python


Language; Basic syntax, Interactive shell, Editing, saving using.py extension, Running and
execution of a script with prompt and applications areas; understanding use of input and
print function; Numbers: Binary, octal, hexadecimal number; type casting; operator and
expressions.
History of Python Language
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python
is a popular programming language. It was created by Guido van Rossum, and released in 1991.
Key Points :

 Python laid its foundation in the late 1980s.

 The implementation of Python was started in December 1989 by Guido Van Rossum at CWI in the Netherlands.

 In February 1991, van Rossum published the code (labeled version 0.9.0) to alt.sources.

 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce.

 Python 2.0 added new features like a list comprehension & garbage collection system.

 On December 3, 2008, Python 3.0 (also called “Py3K”) was released. It was designed to rectify fundamental flaw of the language.
What can Python do?

 Python can be used on a server to create web applications.

 Python can connect to database systems. It can also read and modify files.

 Python can be used to handle big data and perform complex mathematics.

 Python can be used for production-ready software development.


Why Python?
 Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).

 Python has a simple syntax similar to the English language.

 Python has syntax that allows developers to write programs with fewer lines than
some other programming languages.
Python Syntax compared to other programming languages

 Python was designed for readability, and has some similarities to the English language
with influence from mathematics.

 Python uses new lines to complete a command, as opposed to other programming


languages which often use semicolons or parentheses.

 Example : print (“hello”)

Out put : hello


Python Version

Python Version Released Date

Python 1.0 January 1994

Python 1.5 December 31, 1997

Python 1.6 September 5, 2000

Python 2.0 October 16, 2000

Python 2.1 April 17, 2001

Python 2.2 December 21, 2001

Python 2.3 July 29, 2003


Python Version

Python 2.4 November 30, 2004

Python 2.5 September 19, 2006

Python 2.6 October 1, 2008

Python 2.7 July 3, 2010

Python 3.0 December 3, 2008

Python 3.1 June 27, 2009

Python 3.2 February 20, 2011

Python 3.3 September 29, 2012

Python 3.4 March 16, 2014

Python 3.5 September 13, 2015

Python 3.6 December 23, 2016

Python 3.7 June 27, 2018

Python 3.8 October 14, 2019

Python 3.9 October 5, 2020

Python 3.10 October 4, 2021

Python 3.11 October 24, 2022

Python 3.12 October 2, 2023


Python 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.
Python Features

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) 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.
Python Applications
Python Input Function
Python input() function is used to get input from the user. It prompts for the user input
and reads a line. After reading data, it converts it into a string and returns that. It throws
an error EOF Error if EOF is read.
Python input() Function Example 1
Here, we are using this function get user input and display to the user as well.
# Python input() function example
# Calling function
val = input("Enter a value: ")
# Displaying result
print("You entered:",val)
Output:
Enter a value: 45
You entered: 45
Python print() Function

Python print() function prints the given object on the screen or other
standard output devices.

Example:

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


Typecasting in Python

One of the key features in Python is "Typecasting". Typecasting in Python allows programmers to convert variables or
data from one data type to another. It enables smooth manipulation of data. Typecasting in Python can be very useful in
dealing with large data sets where the data is present in different data types. We can convert mutable datatypes into
immutable ones and vice versa.
Common Typecasting Techniques in Python : Python offers two ways to perform typecasting.
• Implicit typecasting

• Explicit typecasting

• 1. Implicit Typecasting in Python : Implicit typecasting is performed automatically by the interpreter, without user
intervention. Python automatically converts one data type to another data type. This process doesn’t need any user
involvement Python promotes the conversion of lower data type, for example, integer to higher data type says float
to avoid data loss. This type of conversion or type casting is called UpCasting.
Example of Implicit Typecasting in Python
# Python Automatically converts
# a to int
a=7
Print (type(a))

# Python Automatically converts


# b to float
b=3.0
Print (type(b))

# c to float as it is a float addition


c=a+b
Print(c)

Output: <class ‘int’>


<class ‘float’>
<class ‘float’>
Explicit Type Conversion in Python

In this method, Python needs user involvement to convert the variable data type into the required data
type.
# initializing integer

s = '4'

# printing character converting to integer

c = ord(s)

print ("After converting character to integer : ",end="")

print (c)

# printing integer converting to hexadecimal string

c = hex(56)

print ("After converting 56 to hexadecimal string : ",end="")

print (c)

# printing integer converting to octal string

c = oct(56)

print ("After converting 56 to octal string : ",end="")

print (c)
Output

After converting character to integer : 52


After converting 56 to hexadecimal string : 0x38
After converting 56 to octal string : 0o70

You might also like