Bitwise Operators: ================== 1) Left shift operator ====================== ==> binary operator ==> symbol: << Syntax: operand1 << operand2 ex: 8 << 2 Math Equation: operand1 X 2^operand2 Note: ===== By doing the left shift on the data, the data can be get double. 2) Right Shift operator ======================= ==> binary operator Syntax: operand1 >> operand2 Ex: 8 >> 2 Note: ==== By doing the right shift, the value should be halved. ============================ IO Operations ============= IO ==> Input and Output Operations Input Operation: ================ Compile Time Input Definition: ============================== x = 10 y = 20 print(x+y) ==> 30 Ex: Signup ==> Zoom Browser ==> do you want to save this password and user name? yes zoom ==> login ==> fixed data Run Time Input Definition: ========================== ==> to run the application with different data for every time, we can define the variables in run time. input(): ======== Syntax: variable-name/identifier = input() Note: ==== input() by default able to read/accept any value as string type. Type Casting: ============= ==> Type Conversion ==> convert any data/value into another datatype ==> In two ways: 1) Implicit Type conversion/Automatic Type Conversion ===================================================== a = 100 # integer b = 3 # integer print(type(a)) print(type(b)) c = 0 print(type(c)) c = a/b print(c,type(c)) 2) Explicit Type Conversion =========================== ==> pre-defined functions: int() a = "100" # b = "abcd" # if the string with other than decimal digits, we can't convert into integer # b = 12-23j b = True c = 12.12 d = 0o123 print(type(a)) # print(type(b)) print(type(b)) print(type(c)) print(type(d)) # int() ==> convert any value to integer type # print(type(int(a))) # print(type(int(b))) p = int(a) # q = int(b) # decimal ==> 0 to 9 Type Error # q = int(b) # Type Error, complex number cannot possible to integer conversion q = int(b) # 1 r = int(c) s = int(d) print(type(p)) # print(type(q)) print(type(q)) print(type(r)) print(s,type(s)) float() complex() bool() str() Q: WAP TO ACCEPT TWO INTEGER VALUES AND PERFORM THE MULTIPLICATION PRINT ITS RESULT. Syntax: var1 = int(input()) a = int(input("Enter a value:")) b = int(input("Enter a value:")) print(type(a),type(b)) res = a * b print("The Multiplication Result = ",res) Q: WAP TO ACCEPT BINARY VALUE, OCTAL VALUE AND HEXA-DECIMAL VALUE AS INPUT AND PRINT ITS CORRESPONDING DECIMAL VALUES. Syntax: val1 = int(input(),2) # binary value val2 = int(input(),8) # Octal value val3 = int(input(),16) # hexadecimal value a = int(input("Enter a binary value:"),2) # binary value b = int(input("Enter an Octal value:"),8) # octal value c = int(input("Enter an Hexadecimal value:"),16) # hexadecimal value print(type(a),type(b),type(c)) print(a,b,c) ======================================= float() ======= print(float(123)) # decimal to float print(float(0b1100101)) print(float(True)) # print(float(1.23-23j)) complex to float is not possible print(float('123')) print(float('123.234')) # print(float('abc')) ==> float(input()) a = float(input("Enter a float value:")) print(type(a)) =================================== complex() ========= print(complex(123)) print(complex(123.234)) print(complex(True)) print(complex('100')) print(complex('123.234')) print(complex('12-23j')) # print(complex('a')) ================================= bool(): ======= print(bool(123)) print(bool(0)) print(bool(-123)) print(bool(0.0)) print(bool(1.23)) print(bool(1-0j)) print(bool(0-0j)) print(bool('')) print(bool('abcd')) ================================= str() ===== print(str(100)) print(str(123.009)) ============================================= ======================================== Output Operations: ================== print() ======= a = 0b11001 b = 0O1234 c = 0Xaf123 print(bin(a),oct(b),hex(c)) # printing multiple values using single print() # print() block line function print("Hello") # the given binary value is = value print("The Given binary Value = ",bin(a)) print("The Given octal value = ",oct(b)) print("The Given Hexadecimal value = ",hex(c)) # The given binary is = value and the given octal = value ,... print("The Binary value = ",bin(a),"The Octal Value = ",oct(b),"The Hexadecimal value = ",hex(c)) print("The Binary Value = {},The Octal Value = {} and The Hexadecimal Value = {}".format(bin(a),oct(b),hex(c))) print("The Decimal for binary = {} for Octal = {} and for hexadecimal = {}".format(a,b,c)) Assignment: ================== 1) WAP TO TAKE/ACCEPT COMPLEX VALUE AS INPUT AND PRINT. 2) WAP TO TAKE BOOLEAN VALUES AS INPUTS AND PERFORM ARITHMETIC OPERATIONS ON THOSE BOOLEAN VALUES AND PRINT RESULTS.