Variables:
Variables are reserved memory locations to store values. Which means that when you create a variable, will reserve some space in memory.
Note:
Python variables do not need explicit declaration to reserve memory space other languages like Java,C etc.,
The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.
So, in-turn, we should only focus on assignment of variable.
Two ways of assignments:
Variables are reserved memory locations to store values. Which means that when you create a variable, will reserve some space in memory.
Note:
Python variables do not need explicit declaration to reserve memory space other languages like Java,C etc.,
The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.
So, in-turn, we should only focus on assignment of variable.
Two ways of assignments:
- Single variable assignment
- Multiple variable assignment
Example:
Python Standard Data Types:
Python has five standard data types
- Numbers
- String
- List
- Tuple
- Dictionary
1.Numbers:
Number data types store numeric values.
Python supports four different numerical types
- integers -> a=15
- long integers -> a=1888L
- floating point -> a=9.8
- complex numbers -> a=1+2j
Note:
A complex number consists of pair of real floating-point numbers denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.
2.Strings:
Strings are contiguous set of characters represented in the quotation marks either single or double.
Subsets of strings can be taken using the slice operator ([ ] and [:])
3.List:
A list contains different type of items are separated by commas and enclosed within square brackets ([]).
The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 and to end -1.
4.Tuple:
- Tuples are similar to Lists unless it is read-only.
- A tuple consists of a number of values separated by commas and enclosed within parentheses().
The main differences between lists and tuples:
- Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed,
- Tuples are enclosed in parentheses ( ( ) ) and cannot be updated.
Note:
The tuples improves the read access for large data-set operations.
5.Dictionary:
Python's dictionaries are kind of hash table type and consist of key-value pairs.
Enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]).




Comments
Post a Comment