Basics of Python
Basics of Python
Agenda
• About ExcelR
• Courses offered in ExcelR
• Anaconda Installation
• Introduction to Python
• Data Types
• Operators
About ExcelR
Allows Duplicate Allows Allows duplicate Members Does not allow duplicate Does not allow duplicate
Members Duplicate members members
Members
Empty String=“ ” Empty List=[ ] Empty Tuple=() Empty set={ } Empty Dictionary={ }
String with single List with single Tuple with single Set with the single Dictionary with {Hello:1}
Element=“H” Item=[“Hello”] Item=(“Hello”) Item={1,2,3,4,5}
Dictionary
• A dictionary in Python is a data structure that stores the value in
key:value pairs. Dictionaries are mutable, dynamic, and can be
nested. Dictionaries are different from lists primarily in how
elements are accessed: while lists are indexed by numbers,
dictionaries are indexed by keys
Example:# Creating a dictionary with integer keys
Dict={1:’Geetha',2:’Anitha’,3:Ramesh'}
Set
• Example:
• x={Geetha,Anish,Amith}
• Type(x)
List
• Lists are used to store multiple items in a single variable. Lists are
created using square brackets:
• Example
• x = ["apple", "banana", "cherry"]
print(x)
Tuple
• Tuples are used to store multiple items in a single
variable.
• Tuple is one of 4 built-in data types in Python used to
store collections of data, the other 3 are List, Set, and
Dictionary, all with different qualities and usage.
• A tuple is a collection which is ordered
and unchangeable.
• Tuples are written with round brackets.
Strings
• Strings in python are surrounded by either single quotation marks, or
double quotation marks. A String is a data structure in Python that
represents a sequence of characters. It is an immutable data type,
meaning that once you have created a string, you cannot change it.
Strings are used widely in many different applications, such as
storing and manipulating text data, representing names, addresses,
and other types of data that can be represented as text.(
• Example
• Print(“hello world”)
Python Range
• Create a sequence of numbers from 0 to 5, and print each
item in the sequence:
• x = range(6)
• The range() function in Python returns a sequence of numbers in a given range. The most
common use of it is to iterate over a sequence of numbers using Python loops 1.
• The syntax of the range() function is:
• range(start, stop, step)
• The parameters are:
• start: the starting value of the sequence (optional, default is 0)
• stop: the end value of the sequence (exclusive, required)
• step: the difference between two consecutive values in the sequence (optional, default is 1)
• Hands on session using Python for different data
Types
Python Variables
• Python Variables are containers for storing data
values
Rules for Python variables:
• 3) A variable name can only contain alpha numeric character and underscores(A-Z,0-9and_)(No symbols
are allowed as a variable Name
• 4)Variable names are case sensitive(age,Age and AGE are three different variables)
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
Thank You