ممكن شرح بالتفصيل لهذا السؤال اذا سمحتم
def showBytesFirstName(megabytes): # converting into bytes
byte=megabytes*1024*1024 # 1MB=1024*1024 bytes
print("\n")
print(megabytes,"Megabytes is",byte,"Bytes.")
def showKiloBytesFirstName(megabytes): # converting into Kilo bytes
kbyte=megabytes*1024 #1MB=1024 KiloBytes
print("\n")
print(megabytes,"Megabytes is",kbyte,"KiloBytes.")
def showGigaBytesFirstName(megabytes): #Converting into GigaBytes
gbyte=megabytes/1024 #1024 MB= 1Giga Bytes
print("\n")
print(megabytes,"Megabytes is",round(gbyte,6),"GigaBytes.") #round function rounds a float upto 6 digit
def showTeraBytesFirstName(megabytes): #converting into TeraBytes
tbyte=megabytes/(1024*1024) #1024*1024 MB= 1 Tera Bytes
print("\n")
print(megabytes,"Megabytes is",round(tbyte,6),"TeraBytes.")#rounding a float upto 6 digit
def menuFirstName():
while(1): # loop countinue until 5 is pressed
num = int(input("""
1: Convert to bytes
2: Convert to KiloBytes(KB)
3: Convert to GigaBytes(GB)
4: Convert to TeraBytes(TB)
5: Quit the program
Please enter your choice: """))
if(num==5): # if 5 is pressed loop will break program terminated
print("Bye!")
break
elif(num<5): #if num is less than 5 we will ask user to enter Mega bytes
megabytes=int(input("Enter Data in MegaBytes (MB)"))
if(num==1): # if num==1 calling bytes method
showBytesFirstName(megabytes)
elif(num==2): #if num=2 calling kilobytes
showKiloBytesFirstName(megabytes)
elif(num==3): #if num=3 calling giga bytes
showGigaBytesFirstName(megabytes)
elif(num==4):#if num==4 calling tera bytes
showTeraBytesFirstName(megabytes)
else: #else loop will countinue
print("\n")
print("Please Enter Valid Choice")
menuFirstName()