Skip to main content

3)Python - Variable Types:

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:

  1. Single variable assignment
  2. Multiple variable assignment
Example:




Python Standard Data Types:

Python has five standard data types
  1. Numbers
  2. String
  3. List
  4. Tuple
  5. 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

Popular posts from this blog

2)Print function,Strings and Math basic calculations:

Print function, Strings and Math basic calculations: Print function: print() function in Python is a function that outputs to your console window whatever you say you want to print out. Strings: Strings are just "strings" of text. Note: The quotes may be single or double else you can escape them using backslash(\) . Example: Concatenation: use the "," -> it will print them out separately with a space. use the "+" -> join integers and floats together, then you will perform an arithmetic operation. Example: Math basic calculations: In python, math calculations are pretty simple enough and cool. Example:

1)About Python Programming and environment setup steps

Step 1: Should be familiar with Python Programming: Let's think about Why Python? Python is a general-purpose language, which means it can be used to build about anything, will be made our programming easy with the right tools/libraries. Professionally, Python is great for web development, data analysis, artificial intelligence and scientific computing.  Note: Python developers used to build productivity tools, games, desktop apps and so on. Before to start programming, lets get download the latest version of python from https://www.python.org/ . which means in my case it's 3.6.4. Installation: Note: Also download the python IDE(pycharm) to make our code more precisely ordered.