Type Conversion
Type Conversion: String Slicing Obtaining a part of a string is called string slicing. Code 1 variable_name [ start_index : end_index ] PYTHON Start from the start_index and stops at end_index end_index is not included in the slice. Code 1 2 3 message = "Hi Ravi" part = message [ 3 : 7 ] print ( part ) PYTHON Output Ravi Slicing to End If end index is not specified, slicing stops at the end of the string. Code 1 2 3 message = "Hi Ravi" part = message [ 3 : ] print ( part ) PYTHON Output Ravi Slicing from Start If start index is not specified, slicing starts from the index 0. Code 1 2 3 message = "Hi Ravi" part = message [ : 2 ] print ( part ) PYTHON Output Hi Checking Data Type Check the datatype of the variable or value using type() Printing Data Type Code 1 2 3 print ( type ( 10 )) print ( type ( 4.2 )) print ( type ( "Hi" )) PYTHON Output <class 'int'> <class 'float'> <class 'str'> T...