hWrite a program to perform conversion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

hWrite a program to perform conversion

tell

2nd Sep 2017, 9:33 AM
nabham sharma
nabham sharma - avatar
5 Answers
0
kr lia mne
3rd Sep 2017, 6:52 PM
nabham sharma
nabham sharma - avatar
0
a=int(input("CHOOSE YOUR NUMBER SYSTEM :\nFor DECIMAL - Press 1\nFor BINARY - Press 2\nFor OCTAL - Press 3\nFor HEXADECIMAL - Press 4\n")) if a==1: b=int(input("Alright !! Now Tell me in which number system you want to convert?\npress 1 for binary\npress 2 for octal\npress 3 for hexadecimal\n")) c=int(input("\n********************************************************************************\n\nENTER\n\nIN DECIMAL NUMBER = ")) if b==1: print( "IN BINARY NUMBER SYSTEM = ",bin(c)[2:],"\n\n********************************************************************************") elif b==2: print("IN OCTAL NUMBER SYSTEM = ",oct(c)[2:],"\n\n********************************************************************************") elif b==3: print("IN HEXADECIMAL NUMBER SYSTEM = ",hex(c)[2:],"\n\n********************************************************************************") else : print("invalid selection","\n\n********************************************************************************") if a==2: b=int(input("In which number system you want to convert\npress 1 for decimal\npress 2 for octal\npress 3 for hexadecimal\t")) c=input("\n********************************************************************************\n\nENTER\n*BINARY NUMBER = ") if b==1: print("IN DECIMAL NUMBER SYSTEM = ",int(c,2),"\n\n********************************************************************************") elif b==2: print("IN OCTAL NUMBER SYSTEM = ",oct(int(c,2))[2:],"\n\n********************************************************************************") elif b==3: print("IN HEXADECIMAL NUMBER SYSTEM = ",hex(int(c,2))[2:],"\n\n********************************************************************************") else : print("invalid selection","\n\n********************************************************************************") if a==3: b=int(input("In which number system you want to convert
3rd Sep 2017, 6:53 PM
Shivam Lives
Shivam Lives - avatar
0
if a==3: b=int(input("In which number system you want to convert\npress 1 for decimal\npress 2 for binary\npress 3 for hexadecimal\t")) c =input("\n********************************************************************************\n\nENTER\n*OCTAL NUMBER = ") if b==1: print("IN DECIMAL NUMBER SYSTEM = ",int(c,8),"\n\n********************************************************************************") elif b==2: print("IN BINARY NUMBER SYSTEM = ",bin(int(c,8))[2:],"\n\n********************************************************************************") elif b==3: print("IN HEXADECIMAL NUMBER SYSTEM = ",hex(int(c,8))[2:],"\n\n********************************************************************************") else : print("invalid selection","\n\n********************************************************************************") if a==4: b=int(input("In which number system you want to convert\npress 1 for decimal\npress 2 for binary\npress 3 for octal\t")) c=input("\n********************************************************************************\n\nENTER\n*HEXADECIMAL NUMBER = ") if b==1: print("IN DECIMAL NUMBER SYSTEM = ",int(c,16),"\n\n********************************************************************************") elif b==2: print("IN BINARY NUMBER SYSTEM = ",bin(int(c,16))[2:],"\n\n********************************************************************************") elif b==3: print("IN OCTAL NUMBER SYSTEM = ",oct(int(c,16))[2:],"\n\n********************************************************************************") else : print("invalid selection","\n\n********************************************************************************") print("\n\t\t\t\t\t\t\t\t\t\t\t\tMADE BY : SHIVAM KUMAR \n\t\t\t\t\t\t\t\t\t\t\t\tUID : 16BEC1069") print("\n\t\t\t\t\t\t\t\t\t\t\t\tNow you understand how it works!! \n\t\t\t\t\tTHANKYOU!!!!") input("Press enter to exit ")
3rd Sep 2017, 6:54 PM
Shivam Lives
Shivam Lives - avatar
- 1
Hey!Nabham Here is What you want!! #NUMBER SYSTEM (DICEMAL,BINARY,OCTAL,HEXADECIMAL) converter print("\n\n\t\t\t\t\t\tWELCOME TO NUMBER SYSTEM CONVERTER(Please view in Full Screen )\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") print("""\n\t\t\t\t SUBMITTED BY : SHIVAM SINGH | ECE-2 | Chandigarh university |\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++""") #Giving some useful information to the user print("""\n\t\t\t\t first Let's understand What is Number System ?\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n Well!! I gonna tell you!!\n Number System are the technique to represent numbers in the computer system architecture,\nEvery value that you are saving or getting into/from computer memory has a defined number system. \n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n\t\t\tThe number systems are mainly of four types:\n * Decimal System: 0,1,2,3,4,5,6,7,8,9 (i.e. base or radix 10 system) * Binary system: 0, 1 (i.e. base or radix 2 system) * Octal System: 0,1,2,3,4,5,6,7 (i.e. base or radix 8 system) * Hexadecimal System: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F (i.e. base or radix 16 system) To understand the concept i had made a conversion calculator of number system \n\n\t\t\t\t\t\t LET'SEE!!********************************************************************************************************************************************************************""") #Taking input from the user a=int(input("CHOOSE YOUR NUMBER SYSTEM :\nFor DECIMAL - Press 1\nFor BINARY - Press 2\nFor OCTAL - Press 3\nFor HEXADECIMAL - P
3rd Sep 2017, 6:50 PM
Shivam Lives
Shivam Lives - avatar
- 1
SEE THIS PROGRAM IN INCRESING PAGE ORDER!!!!!means last page first!!
3rd Sep 2017, 6:55 PM
Shivam Lives
Shivam Lives - avatar