Simple operation on PYTHON
Generally following operation can be performed by the python:
-
Addition (+)
-
Subtraction(-)
-
Multiplication(*)
-
Division(/)
-
Modulus(%)
let study the operation in details:
-
Addition:
Bascially addition means adding up two number.Following operation can be performed in two manner
-
By adding it directly.
- write the two number to be add
- output will be given.
so the output will be shown:
-
By writing a code.
- open IDLE
- click on the file.
- click on NEW.
- write the required code.
- output will b shown.
CODE:
this is the required code
The run the following code:
output:
hence in this way both program can performed.
2. Subtraction:
In python (-) symbol represent subtraction.
basically subtraction means subtracting two number
this can be performed in two manner
- by subtracting directly :
- first we will open idle
- type the number you want to subtract.
- finally it will show you the output.
- by writing code
- first we will open idle.
- then click on file.
- click on new file.
- type the required code their.
- then press RUN
- output will be shown.
output:
3. Multiplication:
In python (*) asterisk symbol is used to perform multiplcation.
there are two ways to multiply the number in IDLE software.
- By multiplying them directly.
- first write the number that you have to multiply.
- the required output will be shown.
output:
- By writing code.
- Open the IDLE.
- click on file.
- click on NEW.
- write the required code
CODE:
OUTPUT:
4.Division:
In python (/) following symbol is used to perform division.
there are two ways to perform division.
- By directly dividing the number.
- OPen IDLE.
- then type the number you want to divide
- output will be shown.
- By writing the code:
- Open IDLE.
- click on NEW.
- type the required code.
- the output will be shown.
CODE:
OUTPUT:
5.MODULUS:
firstly what is modulus is the remainder when in number id divided.
it’s a whole number.
for example
5%2=1
hence 1 is modulus here
In python (%) following symbol is used to do the program.
there are two ways to perform the following function.
- By direct method
- By writing code
- Direct method :
- in this method we write the number directly on IDLE screen
- like given below…
OUTPUT:
- CODE method:
- In this method we have to first Open IDLE.
- Then click on file
- click NEW
- write the required code
- output will be shown.
CODE:
OUTPUT: