BAREBONES OF A PYTHON PROGRAM :
- Expression:
Expression is evaluated and produces the results.
Ex: (10=2)/2 - Statements:
Indicates that we are doing something.
Ex: a=10
print("Calling in proper sequence") - 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 ''' - Function:
A function is a block of code which only runs when it is called. Ex: get Student Marks()
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 VARIABLE IS NOT CREATED UNTIL SOME VALUE IS ASSIGNED TO IT.
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 .
=>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