Python Basic Tutorials

Python is a high level general purpose programming language which has a clear/easy learning curve. Python programming language is massively used in various domains like Artificial Intelligence, Data Science, Web Development, Utilities Tools and Scripts and many more

Python is a Programming language, and the default Python we use is written in C programming language which is also referred to as CPython (Python implementation in C). There are various implementation of Python Programming language i.e Jython(in JAVA), Skulpt(in JS) e.t.c

To make everything easy: We refer CPython as Python

Python Arithmetic Operator

Arithmetic operators are those operators which are used to perform various mathematical operations. For example, '+', '-', '*', '/'.

Operators are discussed here:

Operators Operator meanings Examples
+ Add operands 2+3=5
- Subtraction between operands 3-2=1
* Multiplication between operands 3*2=6
/ Division operator 5/2=2.5
% remainder or modulo operator 5%2=3
// Floor division 5//2=2
** Exponent Operator 5**2=125
Operation examples:

>>>x = 3
>>>y = 2

>>>print('x + y =',x+y)
   x + y = 5

>>>print('x - y =',x-y)
   x - y = 1

>>>print('x * y =',x*y)
   x * y = 6

>>>print('x / y =',x/y)
   x / y = 1

>>>print('x // y =',x//y)
   x//y = 1

>>>print('x ** y =',x**y)
   x ** y = 27
    
Some Examples:


number = input("Enter a number: ")
number = int(number)  # convert to integer
square = number ** 2  # notice the use of exponent operator
cube = number ** 3
print("square is:", square)
print("cube is:", cube)
Output:
Enter a number: 2
square is: 4
cube is: 8


number = 10
if number%2==0:  #notice the use of the modulo operator
    print("Even")
else:
    print("Odd")