Syntax and Numerical Operators
Lets start understanding some of the syntax and operators...
Printing to the console
This is how a console window looks like.
One of the Python's simplest directives is the print directive. When executed, it prints out the stringified version of whatever we passed into it, and then appends a new line under that.
In Python 3, we have to use parentheses:
print('Python 3')
Arithmetic Operators
Similar to other programming languages, Python allows the use of standard arithimetic operators.
The four standard operators perform addition, subtraction, multiplication and division. The operators are +, -, *, /, respectively.
Here they are in use:
Printing to the console
This is how a console window looks like.
One of the Python's simplest directives is the print directive. When executed, it prints out the stringified version of whatever we passed into it, and then appends a new line under that.
In Python 3, we have to use parentheses:
print('Python 3')
Arithmetic Operators
Similar to other programming languages, Python allows the use of standard arithimetic operators.
The four standard operators perform addition, subtraction, multiplication and division. The operators are +, -, *, /, respectively.
Here they are in use:
>>> 210+32
# 242
>>> 6-43
# - 37
>>> 9*8.12
# 73.08
>>> 62/9
#6.8888.....
In Python 3, using the division operator (/) will return a float.
If you want to perform floor division, use the // operator
>>> 62//9
When performing floor division with the (//) operator you are effectively returning only the integer part with the digit after the decimal point being removed.
That's all for today. Try this at home and comment me how it was. Is it working or not? If any doubt comment me. It will surely be solved.
Enjoy learning! conquer the concepts with concept conquerer.
Comments
Post a Comment