Operators
Operators are used to perform operations on variables and values
Arithmetic Operators
Used to perform basic mathematical operations like addition, subtraction, multiplication and division
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a % b)
print(a ** b)
print(a // b)
Output:Enter first number:10
Enter second number:20
30
-10
200
0.5
10
100000000000000000000
0
Comparison Operators
Comparison or relational operators that compares the value and returns whether the condition is true or false
a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
print(a > b)
print(a < b)
print(a == b)
print(a != b)
print(a >= b)
print(a <= b)
Output:Enter first number:10
Enter second number:2
True
False
False
True
True
False
Logical Operators
Perform Logical AND, Logical OR and Logical NOT operations
a = True
b = False
print(a and b)
print(a or b)
print(not a)
Output:False
True
False
Assignment Operators
Used to assign values to variables
a = 10
a += 5
print(a)
a -= 5
print(a)
a *= 5
print(a)
a <<= 1
print(a)
a >>= 1
print(a)
Output:15
10
50
100
50
Ternary Operator
Allows to assign one value if a condition is true, and another if it is false
a, b = 10, 20
min = a if a < b else b
print(min)
Output:10
What is Run time?
Runtime means the time when a computer program is actively running, or the software environment that lets it run
Runtime is when the finished program actually performs its tasks for the user
What is Compile time?
Compile time is the period when a compiler program translates human-readable source code into machine-readable binary code, syntax and semantic checks occur, and compile-time errors are found
What is System Language?
System Language is a 0's and 1's (signals)
Function
Function is reusable blocks of code
function can be defined using def keyword
def function_name(parameters):
*Function Calling *
def fun():
print("Welcome To Python")
fun()
Output:Welcome To Python
*Function calling with parameter *
def fun(a):
print(a+ "Welcome To Python")
fun("Hello")
Output:HelloWelcome To Python
Function with return
def evenOdd(x):
if (x % 2 == 0):
return "Even"
else:
return "Odd"
print(evenOdd(4))
print(evenOdd(5))
Output:Even
Odd

Top comments (0)