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

Chapter 3 - Data Types

The document discusses Python data types. There are numeric types like int for integers, float for floating point numbers, and complex for complex numbers. There are also sequence types like strings, lists, and tuples. Strings are sequences of characters, lists preserve insertion order and allow duplicates, and tuples are immutable like lists. Sets do not preserve order and do not allow duplicates. Dictionaries store key-value pairs with unique keys. Boolean type represents True and False values. Ranges generate integer sequences.

Uploaded by

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

Chapter 3 - Data Types

The document discusses Python data types. There are numeric types like int for integers, float for floating point numbers, and complex for complex numbers. There are also sequence types like strings, lists, and tuples. Strings are sequences of characters, lists preserve insertion order and allow duplicates, and tuples are immutable like lists. Sets do not preserve order and do not allow duplicates. Dictionaries store key-value pairs with unique keys. Boolean type represents True and False values. Ranges generate integer sequences.

Uploaded by

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

CHAPTER 3 – DATA TYPES

Integer

Python Data Types Float

Number Complex

Boolean

Dictionary

Set

Sequence Type List

String

Tuple

NOTE :- The fundamental data type in python are :- Int, float, complex, str, bool

1. Numeric Data type


 Numeric data type represent numbers
 Numeric data type contain int, float and complex data type
 Int :- Int data type contain integer values e.g. – 10, 20, 999, -120, -3
 Float :- Float data type contain floating point value e.g. – 10.0, 5.0, -45.0
 Complex :- Complex data type represent values in the form of real and imaginary part
e.g. – 10+5i

2. Sequence data type

 String :- String data type is a sequence of characters represented in quotation


marks. We can represent single line and multi-line strings using single quotes and
double quotes. E.g. - ‘Python’ “Python is a
High level programming language’’
 We can use triple quotes to represent single and double represent in a string
e.g. - ‘’’Python is a ‘high level programming language ‘’’

 List :- If we want to represent a group of values as a single entity where insertion


order is preserved and duplicates are allowed then we go for list
 Duplicates are allowed
 Insertion order is preserved
 Heterogeneous elements are allowed
 Growable in nature
 List is represented within square brackets
 E.g. – [10, 20, ‘python’, ‘30’, True]

 Tuple :- Tuple is exactly same as list but tuple is not mutable (i.e. immutable) like list
 Basically tuple is read only version of list
 E.g. – (10, 20, ‘python’, ‘30’, True)

 Set :- If we want to represent a group of values as a single entity where insertion


order is not important and duplicates are not allowed then we use set
 Insertion order is not preserved
 Duplicates are not allowed
 Heterogeneous elements are allowed
 Growable in nature
 Indexing concept is not applicable
 Mutable in nature
 Represented within parenthesis
 E.g. - {0,10, ‘Python’, 99}

 Dictionary :- If we want to represent a group of values in key value manner then we


go for dict data type. In dict data type duplicates keys are not allowed but values
can be duplicated. If we try to use duplicate key then old value of key will be
replaced by the new duplicated key value. Dict data type is mutable and order is not
preserved. Represented using curly braces {}

 Bool :- used to represent Boolean values, only two values are allowed True, False

 Range :- range data type represent a sequence of numbers. The elements present in
a range data type are not modifiable i.e. immutable. We can access values in range
data type using index.

e.g. – range(10) -> generate value from 0 to 9

range (10,20) -> generate value from 10 to 19

range (10,20,2) -> 2 represent increment value, we can put any value in place

2, it generate sequence as 10, 12, 14, 16, 18

You might also like