Python Day -2
Rushikesh J.
Software Test Engineer @Vinz Global | Robot Framework | Manual Testing, Automation Testing | Python | Selenium | GIT | JIRA | Immediate Joiner | API Testing Using Postman | Jenkins
What Is Python : Python is an easy to understand ,general purpose programming language
Developed By Guido van Rossum.
Advantages Of Python:
Operators :
Expression = opreator + operand (X + Y ) here x and y are operands and + is operator
Defination Of Operator -- operators are special symbols, combinations of symbols, or keywords that designate some type of computation
Types Of Operator
Addition
x = 5
y = 3
print(x + y)
Subtraction
x = 5
y = 3
print(x - y)
Division
x = 12
y = 3
print(x / y)
Mod(%)
x = 5
y = 2
print(x % y)
Multiplication(*)
x = 5
y = 3
print(x * y)
Floor Division(//)
x = 15
y = 2
print(x // y)
To the power(**)
x = 2
y = 5
print(x ** y)
= (x=3)
x = 5
print(x)
+=(x+=3 same as x= x+3)
x = 5
x += 3
print(x)
-=(x-=3 same as x = x-3)
x = 5
x -= 3
print(x)
*=(x*=3 same as x = x*3)
x = 5
x *= 3
print(x)
/=(x/=3 same as x = x/3)
x = 5
x /= 3
print(x)
== (True If Equal),
x = 5
y = 3
print(x == y)
# returns False because 5 is not equal to 3
!=(True If Not Equal)
x = 5
y = 3
print(x != y)
# returns True because 5 is not equal to 3
>(Greater Than)
x = 5
y = 3
print(x > y)
# returns True because 5 is greater than 3
<(Less Than)
x = 5
y = 3
print(x < y)
# returns False because 5 is not less than 3
>=(Greater Than Equal To)
x = 5
y = 3
print(x >= y)
# returns True because five is greater, or equal, to 3
<=(Less Than Equal To)
x = 5
y = 3
print(x <= y)
# returns False because 5 is neither less than or equal to 3
and (Returns True if both statements are true)
x = 5
print(x > 3 and x < 10)
# returns True because 5 is greater than 3 AND 5 is less than 10
or (Returns True if one of the statements is true)
x = 5
print(x > 3 or x < 4)
# returns True because one of the conditions are true (5 is greater than 3, but 5 is not less than 4)
not (Reverse the result, returns False if the result is true)
x = 5
print(not(x > 3 and x < 10))
# returns False because not is used to reverse the result
is ( it return true if both object are at the same memory location)
a = 5
b = 5
print(id(a))
print(id(b))
print(a is b)
# return true if id(a) and id(b) is same
in (Returns True if a sequence with the specified value is present in the object)
x = ["apple", "banana"]
print("banana" in x)
# returns True because a sequence with the value "banana" is in the list