Playing with Numbers and Variables in Python
We will try to learn how to do declare number types (integer, floating points) arithmetic expressions in python.
Lets start:
First we will try doing simple arithmetic expressions on numbers :
For Addition, use '+'
For Subtraction, use '-'
For Multiplication, use '*'
For Floating point division, use '/'
For Integer division, use '//'
For a raise to b, use a ** b.
Lets demonstrate :
if you want to find the speed of a train, the formula is :
speed = distance / time
Instead of repeatedly using values, you can use variables, lets try it out :
And yes, you can use '#' to write comments
whatever you write after '#' will not be processed!!! :)
Lets start:
First we will try doing simple arithmetic expressions on numbers :
For Addition, use '+'
For Subtraction, use '-'
For Multiplication, use '*'
For Floating point division, use '/'
For Integer division, use '//'
For a raise to b, use a ** b.
Lets demonstrate :
if you want to find the speed of a train, the formula is :
speed = distance / time
Instead of repeatedly using values, you can use variables, lets try it out :
And yes, you can use '#' to write comments
whatever you write after '#' will not be processed!!! :)
Comments