Python bytes() and bytearray() Function

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

#bytes and bytearray collection in Python
#mybyte=bytes([10,4,6,255,45,10])  #immutable
# mybyte[2]=60
# print(type(mybyte))

# for x in mybyte:
#     print(x)
# for i in range(0,len(mybyte),1):
#     print(mybyte[i])
# i=0
# while(i<len(mybyte)):
#     print(mybyte[i])  
#     i+=1

mybytearr=bytearray([10,4,6,256,45,10]) # Mutable
#print(type(mybytearr))
# print("Before Change: ")
# for x in mybytearr:
#      print(x,end=" ")

# mybytearr[2]=120

# print("\nAfter Change: ")
# for x in mybytearr:
#      print(x,end=" ")

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *