You are on page 1of 18

OVERVIEW OF PYTHON

PYDS: Python for Data Science


AND DATA
STRUCTURE
OUTLINE :
BASICS OF PYTHON
INTRODUCTION TO VARIOUS DATA
TYPES, VARIABLES, EXPRESSIONS
OBJECTS AND FUNCTIONS
PYTHON DATA STRUCTURES
INCLUDING STRING, ARRAY, LIST,
TUPLE, SET, DICTIONARY
OPERATIONS ON DATA STRUCTURES
Introduction
Python is a widely used general-purpose, high level programming language.

It was created by Guido van Rossum in 1991 and further developed by the Python
Software Foundation.

It was designed with an emphasis on code readability, and its syntax allows
programmers to express their concepts in fewer lines of code.

Python is a programming language that lets you work quickly and integrate systems
more efficiently.
Reason for increasing popularity

Emphasis on code readability, shorter codes, ease of writing


Programmers can express logical concepts in fewer lines of code in comparison to
languages such as C++ or Java.
Python supports multiple programming paradigms, like object-oriented, imperative
and functional programming or procedural.
There exists inbuilt functions for almost all of the frequently used concepts.
Philosophy is “Simplicity is the best”.
Features of python
1) Interpreted
◦ There are no separate compilation and execution steps like C and C++.
◦ Directly run the program from the source code.
◦ Internally, Python converts the source code into an intermediate form called bytecodes which is
then translated into native language of specific computer to run it.
◦ No need to worry about linking and loading with libraries, etc.

2) Platform Independent
◦ Python programs can be developed and executed on multiple operating system platforms.
◦ Python can be used on Linux, Windows, Macintosh, Solaris and many more.
Features of python
3) Free and Open Source; Redistributable
4) High-level Language
◦ In Python, no need to take care about low-level details such as managing the memory used by the program.

5) Simple
◦ Closer to English language; Easy to Learn

◦ More emphasis on the solution to the problem rather than the syntax

6) Embeddable
◦ Python can be used within C/C++ program to give scripting capabilities for the program’s users.

7) Robust
8) Exceptional handling features

9) Memory management techniques in built


Features of python
10) Rich Library Support

◦ The Python Standard Library is very vast.

◦ Known as the “batteries included” philosophy of Python ;It can help


do various things involving regular expressions, documentation
generation, unit testing, threading, databases, web browsers, CGI,
email, XML, HTML, WAV files, cryptography, GUI and many more.

◦ Besides the standard library, there are various other high-quality


libraries such as the Python Imaging Library which is an amazingly
simple image manipulation library.
Beauty of Python
Java Code Python Code
public class HelloWorld
{ print("Hello, world!")
public static void main (String[] args)
 {
    System.out.println("Hello, world!");
   }
}
Applications
GUI based desktop applications
Graphic design, image processing applications, Games, and Scientific/ computational
Applications
Web frameworks and applications 
 Enterprise and Business applications 
 Operating Systems 
Education
Database Access
Language Development 
 Prototyping 
Software Development
Organizations using Python
Google(Components of Google spider and Search Engine) 
Yahoo(Maps) 
YouTube 
Mozilla 
Dropbox 
Microsoft 
Cisco 
Spotify 
Quora  
Data Structure in Python
Data structures are the fundamental constructs around which you build your
programs. Each data structure provides a particular way of organizing data so it can
be accessed efficiently, depending on your use case.
Python ships with an extensive set of data structures in its standard library.
However, Python’s naming convention doesn’t provide the same level of clarity that
you’ll find in other languages.
The data structures differ based on mutability and order. Mutability refers to the
ability to change an object after its creation. Mutable objects can be modified,
added, or deleted after they’ve been created, while immutable objects cannot be
modified after their creation. Order, in this context, relates to whether the position
of an element can be used to access the element.
Data Structure in Python
Lists
A list is defined as an ordered collection of items, and it is one of the essential
data structures when using Python to create a project.
The term “ordered collections” means that each item in a list comes with an
order that uniquely identifies them.
When creating a list, all the items in the list should be put in square brackets and
separated by commas to let Python know that a list has been created.
A sample list can be written as follows:
List_A = [item 1, item 2, item 3….., item n]
Data Structure in Python
Lists can be nested: A list can be nested, which means that it can contain any
type of object. It can include another list or a sublist – which can subsequently
contain other sublists itself. An example of a nested list is as follows:
List_A = [item 1, list_B, item 3….., item n]

Lists are mutable: Lists created in Python qualify to be mutable because they
can be altered even after being created. A user can search, add, shift, move, and
delete elements from a list at their own will.
Data Structure in Python
Tuples
A tuple is a built-in data structure in Python that is an ordered collection of objects.
Unlike lists, tuples come with limited functionality.
The primary differing characteristic between lists and tuples is mutability. Lists are
mutable, whereas tuples are immutable.
Tuples cannot be modified, added, or deleted once they’ve been created. Lists are
defined by using parentheses to enclose the elements, which are separated by
commas.
A sample tuple is written as follows:
tuple_A = (item 1, item 2, item 3,…, item n)
Data Structure in Python
Why Tuples are Preferred over Lists ?
Tuples are preferred when the user does not want the data to be modified. Tuples
are immutable, so they can be used to prevent accidental addition, modification,
or removal of data.
Also, tuples use less memory, and they make program execution faster than using
lists.
Lists are slower than tuples because every time a new execution is done with lists,
new objects are created, and the objects are not interpreted just once.
Tuples are identified by Python as one immutable object. Hence, they are built as
one single entity.
Data Structure in Python
Sets
A set is defined as a unique collection of unique elements that do not follow a specific order.

Sets are used when the existence of an object in a collection of objects is more important than
the number of times it appears or the order of the objects.

Unlike tuples, sets are mutable – they can be modified, added, replaced, or removed.

A sample set can be represented as follows:


set_a = {“item 1”, “item 2”, “item 3”,….., “item n”}
Data Structure in Python
Dictionary
Python dictionary is an unordered collection of items. Each item of a dictionary has
a key/value pair.
Dictionaries are optimized to retrieve values when the key is known.
Creating Python Dictionary: Creating a dictionary is as simple as placing items inside curly
braces {} separated by commas.
An item has a key and a corresponding value that is expressed as a pair (key: value).
While the values can be of any data type and can repeat, keys must be of immutable
type (string, number or tuple with immutable elements) and must be unique.
Thanks

You might also like