Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Decipher List of Binary Numbers | Binary Numeral System
Numeral Systems 101

book
Decipher List of Binary Numbers

Congratulations! You are one step closer to being a computer master 😎 Imagine that you can convert even a sequence to a binary code. By the way, if you have a desire to cipher your phone number or date of birth then try it! The more practice, the better!

Uppgift

Swipe to start coding

Here you are going to convert the sequence to a binary representation. The task is still the same 😜 Follow the instructions and fill the gaps. The code leads you to get acquainted with another fascinating sequence, as you remember the explanation is waiting for you at the end of the chapter, be patient.

  1. Create an empty list for storing decimal numbers.
  2. Print the list of binary numbers.
  3. Define the loop that iterates through the binary_list.
  4. Define the loop that executes till the binary_number is 0.
  5. Count the remainder of division binary_number by 10 and assign it to the variable last digit.
  6. Multiply the last_digit by 2 raised to the relevant power.
  7. Add the result to the decimal_number.
  8. Decrease the binary_number 10 times using integer division.
  9. Increase power by 1.
  10. Append the decimal_number to the list of decimal numbers.
  11. Print the list of decimal numbers.

Lösning

binary_list = [1, 111, 1010, 1101]
decimal_list = []
print("The number in binary numeral system is: ", binary_list)
for binary_number in binary_list:
power = 0
decimal_number = 0
while binary_number != 0:
last_digit = binary_number % 10
result = last_digit * pow(2, power)
decimal_number = decimal_number + result
binary_number = binary_number // 10
power = power + 1
decimal_list.append(decimal_number)
print("The number in decimal numeral system is: ", decimal_list)

Note

You received a few numbers from the sequence called "Happy numbers". Have you wondered that such continuity exists?

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 4
binary_list = [1, 111, 1010, 1101]
# Create an empty list for storing decimal numbers
decimal_list = ___
# Output the list of binary numbers
___("The numbers in binary numeral system are:", ___)
# Define the loop that iterates through the binary list
for binary_number in ___:
# Creating value for storing the power
power = 0
decimal_number = 0
# Define the loop that executes till the binary number is zero
while ___ 0:
# Count the remainder of division by 10 and assign it to the variable last digit
___ = binary_number____
# Multiply the last_digit by 2 raised to the relevant power
result = ___ * pow(2, power)
# Add the result to the decimal_number
decimal_number = decimal_number + ___
# Decrease the binary_number 10 times using integer division
___ = binary_number___
# Increase power by 1
___ = power ___ 1
# Append the decimal number
decimal_list.___(___)
# Output the list of decimal numbers
___("The numbers in decimal numeral system are:", ___)

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt