So until now, we have seen the python installation in our systems. Now let us start coding with python fundamentals.
Statements:
Python statements are nothing, but the logical instructions that the interpreter execute. Hence the statements can be in single line (or) multi line statements.
Python statements were categorized into two statements :
Expression statement and Assignment statements.
Expression statements :
The expression statements include several operator expressions like Addition(+), Subtraction(-) , multiplication (*), division(/) and modulo(%). Probably In other words, the expression statement returns a value.
An expression is something that returns a value.
Arithmetic expressions:
(10/2)*3
15
Functional expression:
Every Interpreter/compiler have some predefined function like pow(), sqrt() and so on. And Python interpreter supports this tool.
Pow(2.3)
8
Sqrt(81)
3
Assignments statements :
These type of statements creates a variable and assigns a value to it. Hence the assignment statements logically operate and stores the results in the variable(it operates on LHS and stores on RHS).
Examples:
Test1 =’I love coding’
Id (test1)
Output: 70809568
Test2=’I love coding’
Id(test2)
Output: 70809568
If you seriously noticed the above two variables, namely test1 and test2, therefore the interpreter allocates same memory allocation for both the variables.
Want to become a master in Python visit python online training
Note :
Almost Python allocates same memory location in two cases
If the string is less than 20 characters ( white spaces were included)
Integers ranging between -5 to + 255.
RHS operations :
In this, we have some operations on RHS. Hence, Let us discuss with some examples.
Test =7*2
type(test)
Output : input
Test = 7*2/10
type(test)
Output: float
Comments :
So, these are nothing but the non – executable line of code. While, we have two types of comments.
Single line comments:
The single line comments start with #
# I don’t execute
Multiple line comments :
Finally, the multiple line comments start and end with “ ”.
Would you like to know Is python compiled or interpreted