None Datatype: =========== ==> None ==> keyword used to define a variable with nothing ==?> Non is the value, we can be used to assign the variable Syntax: variable_name = None a = None # a variable without any value assignment print(id(a)) print(a) a = 111 print(a) ========================================= TYPE CASTING ============= ==> ALSO CALLED AS TYPE CONVERSION ==> USED TO CONVERT A DATA FROM ONE FORM (TYPE) TO ANOTHER FORM (TYPE) INT ==> FLOAT FLOAT ==> INT ETC. ==> THE VARIOUS METHODS FOR TYPE CASTING ARE: int() float() complex() bool() str() int() === ==> any data should be converted to integer (decimal) Syntax: int(data) Rules: ==== 1) any base value of an integer type of the data should be possible to convert into decimal bin ==> dec, oct ==> dec, hex ==> dec 2) any float value can be allowed for the decimal conversion. 3) No complex data is possible for decimal conversion. 4) Boolean values are possible for the decimal conversion. True ==> 1 False ==> 0 5) String to integer conversion i) string with only numerals ==> decimal conversion is possible ii) string with otherthan numerals ==> decimal conversion is not possible. print(int(0b110001)) print(int(0o117722)) print(0x11af) print(int(99.79)) print(int(9.779e-2)) # print(int(10-20j)) Type Error print(int(True)) print(int(False)) print(int('12345')) # print(int('12.123')) Value Error # print(int('abcd')) ====================================== float() ==== ==> used to convert any data to floating-point data. Syntax: float(data) Rules: ==== 1) any base value of an integer data ==> float bin ==> float oct ==> float etc. 2) no complex values allowed for the float conversion. 3) Boolean values are allowed for the float conversion. True ==> Decimal 1 ==> Float 1.0 False ==> 0 ==> 0.0 4) String to float conversion: i) if the string with numerals (decimals) ==> possible for float conversion ii) if the string with floats ==> possible for float conversion iii) when the string otherthan the above ==> not possible print(float(0b11001)) # binary ==> decimal ==> float print(float(0o1122)) # octal ===> decimal ==> float print(float(0xaf12)) # hexadecimal ==> decimal ==> float print(float(123)) # print(float(1+20j)) Type Error print(float(True)) print(float(False)) print(float('1234')) # string_decimal ==> decimal ==> float print(float('12.234')) # string_float ==> float # print(float(1-2j)) Type Error ================================================= complex() ======= ==> used to convert any data to complex data. Syntax_1: (with single parameter) complex(value) Here: value ==> Real part rules: ==== 1) any base value of an integer data ==> complex 2) any type float ==> complex 3) boolean ==> complex 4) string ==> complex: i) string with decimal ==> possible ii) string with float ==> possible iii) string with alphabets ==> not possible print(complex(100)) print(complex(0b11001)) print(complex(0o1122)) print(complex(0x1122ff)) print(complex(11.2233)) print(complex(12.34e7)) print(complex(True)) print(complex(False)) print(complex('123')) print(complex('12.23')) # print(complex('0b11001')) Type Error Syntax_2: with two parameters ======= complex(val1,val2) Here: val1 ==> real data ==> +/- val2 ==> imaginary data ==> +/- Rules: ==== 1) any base value of an integer is allowed for real and imaginary value definition. ex: complex(0b11001,0o1122) Note: === if the first parameter of complex() is string type, it does't accept the second parameter. print(complex(100)) print(complex(0b11001)) print(complex(0o1122)) print(complex(0x1122ff)) print(complex(11.2233)) print(complex(12.34e7)) print(complex(True)) print(complex(False)) print(complex('123')) print(complex('12.23')) # print(complex('0b11001')) Type Error # a = 123-0o112j print(complex(100,0b11001)) print(complex(0x1122,0o11223)) print(complex(1000,12.234)) # print(complex('1122','1122')) Type Error print(complex('1122')) print(complex(True,False)) ========================================== bool() ==== ==> used to convert any data to boolean any value other than zero ==> True any value which is zero ==> False ex: bool(1) ==> True bool(1+0j) ==> True print(bool(0b1100)) print(bool(0b00)) print(bool(0x0)) print(bool(1.0)) print(bool(0.00000000)) print(bool(0.00000000000011)) print(bool(12-24j)) print(bool(0j)) print(bool('')) print(bool(' ')) print(bool('a')) print(bool('0')) ================================== str() === ==> used to convert any data into string data. Syntax: str(any data) print(type(str(0b11001))) print(str(0o1122)) print(str(0x1122)) print(str(1122)) print('abcde') print(str(112.113)) print(str(True)) print(str(False)) print(str(11-22j))