Tuesday, May 22, 2018

python chap 4 (Hi friends this is the continuation of previous post so i kindly request you to read that before this post. As this blog is also prepared for beginners so i advice you that you don't need to by-heart this lessons just read and understand it if you have any doubt ask in the comment section)

  

Tokens :

The python program is read by a parser this input to the parser is the tokens which is generated by the lexical analyser . Each token corresponds to the sub string of logical lines the normal token types are identifiers, keywords, operators ,delimiter and literals which will be covered in the coming section. As you may use whitespace between tokens to separate them. Some whitespace seperation is necessary between logically adjacent identifiers or keywords otherwise the python would parse them as single longer identifiers like the statement printj will be a single identifier so to write the j we need to put space between print and j as like print ("j") this will print j .


ASSIGNING VALUES TO VARIABLES

              
                    Python variables do not need explicit declaration to reserve memory space The declaration happens automatically when you assign a value to a variable the equal sign (=)is used to assign a value  to a variable the operand to the left of the equal sign is the name and the other one on the right is the value stored in the variable here is an example :



name_value = "this is a string value "       #this is a string value
num_value =   458
                             #this is a integer value
                        #we will come to string and integer later on

And in python a single value can be assigned to multiple variables simultaneously  for example

a = b = c = 2
here a single value is assigned to multiple variables like the value 1 is assigned to a,b and c and then in python multiple objects can be assigned to multiple variables for example :

a,b,c = 1,2,"nadeem"
In here two numbers 1 and 2 are applied to a and b respectively and nadeem is assigned to c 


DATA TYPES

                                      Data types are simply classification of data in to which tells the compiler or interpreter how the programmer intents to use the data .A data stored in memory can be of different types for example "john" is a string data type and 21 is a integer data type. Python has various standard datatypes that are used to define the operation possible on them and the storage method for each of them . simply the data type determines what kind of operation can be done on the data value. An object which can be altered is known as mutable and which cannot be altered is known as immutable objects (friends you will be confused with objects you will understand it in the coming lessons so be patient).

                                   python has built in data types such as  numbers,strings,lists,tuples and dictionaries and you can also create your user defined types known as classes will be discussed on the coming lessons             

NUMBERS

Number data type store numeric values like 1,2,3 and number objects are created when you assign a value to them. Number object supports integers (long and plain), floating point numbers  and complex numbers. You can also delete a reference to a  number object by the del statement python supports three different numerical types 
  • INTEGER (signed integers like 10,12,-23,-95):
             All integers in python 3 are represented as long integers there is no separate number type as long . python integer literal contains decimal , octal and hexa decimal values
          
  • FLOAT(floating point real vlaues like -21.3,32.3+e18,-32.54e100): 
            The floating point numbers are which contains sequence of decimal digits that includes decimal points(.) an exponent path (an e or E optionally followed by + or - followed by one or more digits ) or both but the leading character of a floating point literal can't be e or E. it may be any digit or period the example for floating point are given above .
  • COMPLEX NUMBERS(3.14j,45.j)
The complex numbers is made up of two floating point values one each for the real and imaginary part for example a complex number consists of an ordered pair of real floating point number denoted by x + yj where x and y are real numbers and j is the imaginary unit

More on number data types and how we can use them will be understood from the coming lessons 
so don't worry if you didn't get all of it .

THANKS FOR VIEWING MY BLOG HOPE YOU LIKE THE POST IF YOU WANT TO GET LATEST POSTS ON THIS PLEASE FOLLOW BY EMAIL ID AND FEEL FREE TO ASK YOUR DOUBTS AND DON'T FORGET TO SHARE,COMMENT AND FOLLOW 

No comments:

Post a Comment