Friday, June 25, 2021

(25-06-21)PYTHON FUNDAMENTALS (PART-3)

 

BAREBONES OF A PYTHON PROGRAM :

  1. Expression:
    Expression is evaluated and produces the results.
    Ex: (10=2)/2
  2. Statements:
    Indicates that we are doing something.
    Ex: a=10
    print("Calling in proper sequence")
  3. Comments:
    Comments are readable messages for a programmer but it is overlooked by the python interpreter.
    a. Single line comment (#)
    b. Multi-line comment (''' ''')
    Ex: #this is a single-line comment
    ''' this is
    multiple '''
  4. Function:
    A function is a block of code which only runs when it is called. Ex: get Student Marks()
Block & Indentation:
A group of statements in block indentation at the same level creates a block. Ex: all the statements that are under the function get Student Marks()

VARIABLES AND ASSIGNMENTS :

A VARAIBLE IN PYTHON REPRESENTS NAMED LOCATION THAT REFERS TO A VALUE AND WHOSE VALUES CAN BE USED AND PROCESSED DURING PROGRAM RUN.
VARIABLES , CALLED SYMBOLIC VARIABLES , SERVE THE PURPOSE.
EG:-
AGE = 15
AGE IS VARIABLE AND 15 IS THE VALUE ASSIGNED TO IT .  

# A VARIABLE IS NOT CREATED UNTIL SOME VALUE IS ASSIGNED TO IT.

=>ASSIGNING SAME VALUES TO MULTIPLE VARIABLES :-
                    
A = B = C = 10

πŸ‘†πŸ‘†THIS WILL ASSIGN VALUE  1O    TO ALL THREE VARIABLES A , B AND C .

=>ASSIGNING MULTIPLE  VALUES TO MULTIPLE VARIABLES :-

X , Y , Z = 10 , 20 , 30

πŸ‘†πŸ‘†THIS WILL ASIGN THE VALUES ORDER WISE .I .E:-
X = 10 
Y = 20
Z = 30

SOME EXAMPLES ---

CODE:    X , Y = 25 , 50                    OUTPUT:   25  50   
                 print(X , Y )
 # HERE THE VALUE IS ORDER WISE ☝πŸ‘€


CODE:   X , Y = Y , X                        OUTPUT:   50  25 
                print(X , Y )
# HERE THE VALUE IS REVERSED OF THE ABOVE CASE ☝πŸ‘€

No comments:

Post a Comment

(11-07-21)DATA TYPES IN BRIEF

  DATA TYPES IN SQL: 1) NUMERIC   2) DATE AND TIME 3)STRING TYPES NUMERIC: #INT :  NORMAL SIZED INTEGER WHICH CAN BE SIGNED OR UNSIGNED.    ...