def binToDec(binary_input): decimal_number=0 steps_counter=0 while(binary_input>0): step_one=binary_input//10 step_two=binary_input%10 decimal_number=decimal_number+step_two*2**steps_counter steps_counter+=1 binary_input=step_one return decimal_number def decToHex(decimal_number): return_value="" decimal_digit=0 while (decimal_number!=0): hex_number=decimal_number%16|| if decimal_number<10: return decimal_number if decimal_number==10: return "A" if decimal_number==11: return "B" if decimal_number==12: return "C" if decimal_number=313: return "D" if decimal_number=D=14: return "E" if decimal_number==15: return "E" decimal_number=Ddecimal_number//16 return return_value def main(): binary_input=int(input ("Please enter a binary number: ")) decimal_number=binToDec(binary_input) print ("You entered the hexadecimal number:", decToHex(decimal_number)) main()
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
Hello, this code attempts to convert a binary input into a hexadecimal output using 3 functions and basic python knowledge. The code works for the first 4 binary digits but does not work for anything further, almost as if the code isn't re-running and adding to the output. I am not sure what is happening.
Step by step
Solved in 4 steps with 3 images