the bytes and bytearray data types python provides two data types for handling raw bytesbytes which is immutableand bytearray which is mutable both types hold sequence of zero or more -bit unsigned integers (byteswith each byte in the range str translate( both types are very similar to strings and provide many of the same methodsincluding support for slicing in additionbytearrays also provide some mutating list-like methods all their methods are listed in tables and whereas slice of bytes or bytearray returns an object of the same typeaccessing single byte using the item access operator ([]returns an int--the value of the specified byte for exampleword "animalx "aword[ = returnsfalse word[: = returnstrue word[ = [ returnstrue word[ = = "aword[: = " " = "aword[ = [ = here are some other bytes and bytearray examplesdata " hills \ \ \ \ \ \ \ data upper(returnsb' hills hillsdata replace( "ill" "at"returnsb' hats hatsbytes fromhex(" "returnsb' hillsbytes fromhex(" "returnsb' hillsdata bytearray(datadata is now bytearray data pop( returns (ord(" ")data insert( ord(" ")data = ' hills billsmethods that make sense only for stringssuch as bytes upper()assume that the bytes are encoded using ascii the bytes fromhex(class method ignores whitespace and interprets each two-digit substring as hexadecimal numberso " is taken to be byte of value and so on pickle dump(selffhpickle highest_protocolreturn true except (environmenterrorpickle picklingerroras errprint("{ }export error{ }formatos path basename(sys argv[ ])err)return false finallyif fh is not nonefh close(