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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:40
Match the personality traits with their description
Answers: 2
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
In three to five sentences, describe how you can organize written information logically and sequentially
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
5.a fishing rod is formed from a composite material of 0.5 kg of glass fibers embedded in a matrix of 0.5 kg of epoxy resin. the glass fibers are assumed to be long, continuous and unidirectional. to achieve a greater stiffness it is proposed to use a different composite that is comprised of long continuous carbon fibers that will be embedded in a matrix of 0.5 kg of epoxy resin. if the modulus of elasticity of the carbon fiber composite is 10% greater than the elastic modulus of the glass fiber composite, estimate the mass of carbon fibers that will be used to make the carbon fiber composite. assume the applied tensile stress is parallel to the direction of the long axis of the fibers. the epoxy resin, glass fiber, and carbon fiber have an elastic modulus of 5, 86, and 350 gpa respectively and a density of 1100, 2500, and 1800 respectively.
Answers: 3
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
question
Computers and Technology, 10.03.2020 01:37
question
Geography, 10.03.2020 01:37
question
Mathematics, 10.03.2020 01:37
Questions on the website: 13722363