0% found this document useful (0 votes)
3 views3 pages

Data Types

The document outlines data types in programming, categorizing them into single value and collection data types. Single value types include Integer, Float, Boolean, and Complex, while collection types consist of String, List, Tuple, Set, and Dictionary, each with distinct properties. Additionally, it explains control flow structures such as If, Else, Elif, For loop, and While loop, highlighting their usage and differences.
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)
3 views3 pages

Data Types

The document outlines data types in programming, categorizing them into single value and collection data types. Single value types include Integer, Float, Boolean, and Complex, while collection types consist of String, List, Tuple, Set, and Dictionary, each with distinct properties. Additionally, it explains control flow structures such as If, Else, Elif, For loop, and While loop, highlighting their usage and differences.
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/ 3

Data Types:

Data types has classified into two categories:


1. Single value data type
2. Collection data type.

Single value data type:


It has four types, they are:
i) Integer:
Any number without decimal part both positive and negative is considered as
integer.

ii) Float:

A number having decimal part both positive and negative is considered as float.

iii) Boolean:

Boolean having only two value i.e., True and False. ● In python True is
considered as ‘1’ and False is considered as ‘0’.

iv) Complex:
Complex data type has two parts i.e., real and imaginary parts

ii. Collection data type:


In this collection data type they are five types, they are:
i) String:
A string is declared using single code (‘ ’), double code (“ ”), and tribble codes
(‘’’ ’’’).

Indexing:
● The starting value should be considered as ‘0’ when it is taken from left to right.
● The starting value should be considered as ‘-1’ when it is taken from right to left.

List:
● Elements inside list is declared using [] square brackets.
● List is ordered data type and it supports indexing.
● List is mutable data type and it can be modified.
● List is both homogeneous and heterogeneous data type.
● Duplicates are allowed in list.
Tuple:
● Elements in the tuple is declared using round brackets ().
● Tuple is ordered data type and it supports indexing.
● Tuple is immutable data type and it cannot be modified.
● Tuple is both homogeneous and heterogeneous data type.
● Duplicates are allowed in tuple.
Set:

● Elements in set is declared using curly/flower brackets {}.


● Empty set is declared using set function N=set ()
● It is unordered data type and it does not support indexing.
● Set is mutable data type.
● Duplicates are not allowed.
● Set is both homogeneous and heterogeneous but it allows immutable data type.

Dictionary:

● Elements in dictionary is stored by curly brackets {}.


● Elements are in form of key and vale pair.
● Key and values are separated by colon (:), key value pair is separated by comma (,).
● It is ordered data type but it does not support indexing.
● It is mutable data type.
● Duplicate keys are not allowed, if we try to add duplicate key then old key is replaced
by new key, whereas duplicate values are allowed.
● Only immutable keys are allowed whereas values can be of any data type.

If block:
● If the given condition is true then control goes to inside if block.
● If block is also called as True block.
● For if block, else block is not mandatory.

Else block:

● if the given conditions are False then control goes to else block.
● Else block is also called as False block.
● For else block, if block is mandatory.

Elif block:

● If previous condition is false then control goes to elif block.


● For one if block we can write multiple elif blocks.
● If there are multiple conditions to check then we use elif blocks.
For loop:

● For loop is used if number of iterations are known.


● For loop is executed only on iterable data types.
● Iterable data types are: string, list, tuple, set, dictionary, range.
● Starting point of execution and ending point of execution both are same.

While loop:

If given condition is False then control comes out of the loop.


If number of iterations are unknown then we use while loop.
a. If given condition is True then control goes inside loop.
b. Starting point of execution and ending point of execution both
are
same.

Difference between for loop and while loop:

c. When we know the number of iterations then we use for loop


whereas in while loop we don’t know the number of iterations.

You might also like