3 Dec 2020

Statements and Expressions

Statements:

              *Instructions that a Python interpreter can executes are called statements.
           *  A statement is a unit of code like creating a variable or displaying a value. 

>>> n = 17
>>> print(n)

Here, The first line is an assignment statement that gives a value to n. 
The second line is a print statement that displays the value of n.



Expressions: 

             * An expression is a combination of values, variables, and operators.
          
              * A value all by itself is considered an expression, and also a variable. So the following are all legal expressions: 

>>> 42
42
>>> a=2
>>> a+3+2
7
>>> z=("hi"+"friend")
>>> print(z)
hifriend

No comments:

Post a Comment

Operator precedence

           When an expression contains more than one operator, the order of evaluation depends on the order of operations.            The ac...