Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

learning python can someone fix the code and explain why the errors happened i dont understanddef bits 2 int ( ) : #public static int

learning python can someone fix the code and explain why the errors happened i dont understanddef bits2int(): #public static int bits2int(){ #Unlike java python doesnt # int currBit; #need me to set int values # int number; number =0 # number =0; currBit = get_bit() # currBit = get_bit(); while currBit !=-1: # while (currBit !=-1){ number = number <<1 # number = number <<1; number = currBit + number # adding bit to number base 2 # number = currBit + number;// building up value currBit = get_bit() # getting next input value # currBit = get_bit();//1,0 # }// end of while return number # return number; #}// end of bits2int def get_bit(): # public static int get_bit(){ user_input=input("") # mips.read_c(); x = chr(user_input) # char x =(char) mips.retval(); if x =='0': # if (x =='0'){ return 0 # return 0; elif x =='1': # }else if(x =='1'){ return 1 # return 1; else: # }else{ return -1 # return -1;// error # }// end of get_bit # Example usage:result = bits2int()print("Result:", result)in coments i have java which works fine

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Create a Fishbone diagram with the problem being coal "mine safety

Answered: 1 week ago

Question

Does it use a maximum of two typefaces or fonts?

Answered: 1 week ago