subject

This is my code and i cant find what the problem is could you help me #!/usr/bin/env python
# coding: utf-8

# In[2]:

while True: # Program will keep running until we quit it ourselves , Infinite loop
print("\n\n BINARY / DECIMAL CONVERSION \n\n") # Title
choice = input("1- Binary to Decimal conversion \n2- Decimal to Binary Conversion \n3- Quit \n\n =>") #Menu

if choice == "1": # binary to decimal
binary = (list(input("\n\nInput a binary number: "))) #input binary number and covert it into list
decimal = 0 #this variable will hold final decimal converted value
i = 0
binary = (list(input("\n\nInput a binary number: ")))
digit = binary. pop() # pop is a method of list which removes and return last item of list
for i in range(len(binary)): #Loop number of digits of binary number time

if digit == '1': #if digit is one , add 2 raised to the power i to the decimal variable

decimal = decimal + pow(2, i)
print("The decimal value of the number is: ", decimal) #print result

if choice =="2":#decimal to binary

decimal = int(input("\n\nInput a Decimal Number: ")) #input decimal number and convert it into integer
i = 0
binary = [] # this list will hold final binary result
while decimal!=0: # while decimal value is not equal to zero
rem = decimal%2 #remainder of decimal divided by 2
binary. insert(i, rem) #insert remainder on ith index of binary list
i = i+1
decimal = int(decimal/2) #dividing list by 2

i = i-1
print("\nThe Binary value of the number is:")
binary. reverse() # We need to reverse the list to get the result we want

for i in range(len(binary)):
print (binary[i],end ="") #printing each index of binary list one by one

if choice == "3":#Quit
print("\n\n Program Terminated Successfully ")
exit() #Terminates the program

# In[ ]:

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:30, SKYBLUE1015
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
image
Computers and Technology, 22.06.2019 17:30, babyface1686
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, larry5007
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
image
Computers and Technology, 24.06.2019 12:00, log40
Jack is assisting his younger sibling mary with her mathematics assignment, which includes a study of the number system. jack explains to mary that whole numbers are counting numbers that could be used to record the number of fruits in a basket. which data type represents whole numbers? a. integers. b.floating-point numbers. c. strings. d.boolean
Answers: 1
You know the right answer?
This is my code and i cant find what the problem is could you help me #!/usr/bin/env python
...

Questions in other subjects: