We are going to start by creating a simple program which displays "Hallow World". In python, we use the print('') statement to get output. The statement is usually put in between the brackets.
Print text.
Print('Hellow World')
Print('Hellow World!')
Print('Hellow World...')
Simple Calculations.
Python is also used to carry out calculations.
Print(2+2)
Print(2+9)
Print(2+8-9)
Multiplication and Division.
We use asterisk * to indicate multiplication and a forward slash / to indicate division.
Print(2*2)
print(2*(3+4))
print(9/3)
Floats.
Floats are used in python to represent numbers that are not integers eg 0.7, -2.341.
They are created by entering a number with a decimal point or using division on interfering.
Print(4/7)
Print(0.56)
Print(5+2.3)
Print(7*8.0)
Exponentials.
In python, exponentials are created by raising a number to the power of another. The operation is done by using two asterisks**.
Print(4**4)
Print(7**(1/2))
Quotient.
In python, floor division is done using two forward slashes //.
Print(19//3)
Print(20//6)
Remainder.
A percentage symbol % is used to get the remainder of a division.
Print(19%3)
Print(20%6).
Follow me for the best level of python basics.
Welcome
ReplyDelete