print function & Variable
print('hello world', "first program") # character should be used in "" or '' as a string
print(20 + 50)
print(30 < 20)
var, no need to define var, number shouldn't be used first, no special character other than _ (underscore)
a = 10
b = 20
print(a + b)
print(id(a), id(b)) # id gives a memory address
a = 10
c = 10
print(id(a), id(c)) # in python the address is created according value , same value = same memory location
String Concatenation
a1 = "String"
b1 = "concatenation"
print(a1 + " " + b1)
Operators
Arithmetic operator X%Y(modulus gives- remainder value), Exponents (x**y), Floor Division (X//y)
print('Operators')
print(5 ** 4) # 5*5*5*5
print(19 // 5) # gives floor value
Assignment Operators
x = 3
print("example assignment operators ", x)
x += 3
print(x) # x= x+3
x -= 2
print(x) # x= x-2
Comparison operators, x==y, x!=y, x>y, x<y, X>=y, x<=y, it gives a Boolean value that is 'True' or 'False'
Logical Operators : and, or, not
print('Comparison and Logical Operators')
x = 10
y = 20
print(x == 10 or x < y or x == y) # any condition is true then output will be true
print(x == 10 and x < y and x == y) # all the condition should be true to get true as an output
print(not x == 10) # not will reverse the output True becomes 'False' and False becomes 'True'
Membership Operator: 'in' and 'not in'
str1 = "Membership Operator"
print(str1)
print('h' in str1) # note: case-sensitive and gives output in boolean vale
li = [40, 50, 40, 40]
print(60 not in li)
Identity Operators: 'is' and 'is not' works like == and != comparison operators
print("Identity Operators")
x = 10
y = 10
print(x is y, x == y)
print(x is not y, x != y)
Bit-wise operators: &(and), |(or), ^(xor) Bit-wise operator truth table 0= false and 1= true , bin function is used to get binary of any numbers