Python
Data Types
Saravanakumar,AP/CSE 2
Data Types
Numbers Type
Saravanakumar,AP/CSE 3
Number
Type
Example
int -8,12
float 3.14
Complex 2+3j
Conversion
Function
Number
System
Prefix Example
Binary 0b or 0B 0b111
Octal 0o or 0O 0O10
Hexadecimal 0x or 0X 0xFF
Decimal
Module
decimal.Decimal(0.1)
Fractions
Module
Fraction(1.5)
Math Module math.exp(3), math.tan(90)
String Type
Saravanakumar,AP/CSE 4
• Python string using either single quotes or double quotes. Example : a='Dogs are love‘ or a="Dogs are love"
Tuples
Saravanakumar,AP/CSE 5
• Python Tuples are like a list. It can hold a sequence of items. Example : Tuple1 = (1,2,5,6) , Tuple2 = (‘a’, “b”, ‘c’, “d”)
Lists
Saravanakumar,AP/CSE 6
• Lists hold different types of data using [] and , . Example : c= ["hey","you",1,2,3,"go"]
Saravanakumar,AP/CSE 7
List Method
Dictionary
Saravanakumar,AP/CSE 8
Dictionary is an unordered sequence of data of key-value pair form {key : value} - similar to the hash table type.
a = {1:"first name",2:"last name", "age":33}
Saravanakumar,AP/CSE 9
Sets
A set is a collection which is unordered and unindexed. In Python sets are written with { }.
thisset = {"apple", "banana", "cherry"}
Saravanakumar,AP/CSE 10

Python data types