def showBytesFirstName(megabytes):# converting into bytes
byte=megabytes*1024*1024# 1MB=1024*1024 bytesprint("\n")print(megabytes,"Megabytes is",byte,"Bytes.")def showKiloBytesFirstName(megabytes):# converting into Kilo bytes
kbyte=megabytes*1024#1MB=1024 KiloBytesprint("\n")print(megabytes,"Megabytes is",kbyte,"KiloBytes.")def showGigaBytesFirstName(megabytes):#Converting into GigaBytes
gbyte=megabytes/1024#1024 MB= 1Giga Bytesprint("\n")print(megabytes,"Megabytes is",round(gbyte,6),"GigaBytes.")#round function rounds a float upto 6 digitdef showTeraBytesFirstName(megabytes):#converting into TeraBytes
tbyte=megabytes/(1024*1024)#1024*1024 MB= 1 Tera Bytesprint("\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 terminatedprint("Bye!")breakelif(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 countinueprint("\n")print("Please Enter Valid Choice")
menuFirstName()
السؤال
محمد فهد خالد
ممكن شرح بالتفصيل لهذا السؤال اذا سمحتم
توضيح السؤال
4 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.