Course Content
Numeral Systems 101
Numeral Systems 101
Get Acquainted with Binary Code
I guess you got wind of the fact that computers see your code differently than you: this bright machine can read binary code, which consists of 0 and 1. The binary code looks like this 00011100, but zeros in forwarding positions are optional, so you can remove it and write the code like 11100. It is easy for a computer, but a challenge for humans; therefore, you are going to get familiar with deciphering it:
Rule
Here you should do the same operations as in the previous chapter. Find the index of a number(it still begins from the right ) and then multiply the current number by 2 raised to the power of the index. For instance 101
->1x2^2
+ 0x2^1
+ 1x2^0
= 4
+ 0
+ 1
= 5
.
Usage of binary system
The main point of using binary code is that a computer consists of billion transistors that respond to binary signals 0
or 1
; hence, "computer words" that include only 0 and 1 send signals to transistors, 1
means on, and 0
means off.
# Defining binary number binary_number = 1010111 #creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in binary numeral system is:", binary_number) # Variable for storing the power power = 0 # The loop executes till the number is zero while binary_number != 0: # The remainder of division by 10 allows us to receive the last digit of a number last_digit = binary_number % 10 # Multiplying digit by 2 raised to the relevant power result = last_digit * pow(2, power) # Adding the result to the current decimal number receive the decimal one decimal_number = decimal_number + result # Decreasing decimal number using integer division by 10, allows getting rid of the last digit binary_number = binary_number // 10 # Increasing power by 1 power = power + 1 # Printing the result print("The number in decimal numeral system is:", decimal_number)
Task
It's time to hone in on your skills! Convert a number from binary numeral system to decimal one and print the result. You should follow the algorithm on the right and fill the gaps. As the result, you will receive one of the magic numbers. But the explanation is waiting for you at the end of the chapter.
- Define the variable
power
and assign0
to it. - Count the remainder of division
binary_number
by10
. - Multiply
last_digit
by the2
raised to the relevant power. - Add the
result
to adecimal number
. - Increase
power
by1
. - Print the
decimal_number
.
Note
I guess that you received 1729 and want to know why I claimed that this number is magic? Everything is completely clear: It is called Hardy-Ramanujan number after an anecdote about one of British mathematician G.H Hardly. If you find this information gripping you can read about the anecdote in 'The Man Who Knew Infinity by Robert Knaigel. It is the smallest number that you can express like the sum of two different cubes in two different ways. 1729 can be calculated as the sum of the cubes of 10 and 9, a cube of 10 is 1000 also the cube of 9 is 729, and the sum of the cubes of 12 and 1.
Thanks for your feedback!
Get Acquainted with Binary Code
I guess you got wind of the fact that computers see your code differently than you: this bright machine can read binary code, which consists of 0 and 1. The binary code looks like this 00011100, but zeros in forwarding positions are optional, so you can remove it and write the code like 11100. It is easy for a computer, but a challenge for humans; therefore, you are going to get familiar with deciphering it:
Rule
Here you should do the same operations as in the previous chapter. Find the index of a number(it still begins from the right ) and then multiply the current number by 2 raised to the power of the index. For instance 101
->1x2^2
+ 0x2^1
+ 1x2^0
= 4
+ 0
+ 1
= 5
.
Usage of binary system
The main point of using binary code is that a computer consists of billion transistors that respond to binary signals 0
or 1
; hence, "computer words" that include only 0 and 1 send signals to transistors, 1
means on, and 0
means off.
# Defining binary number binary_number = 1010111 #creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in binary numeral system is:", binary_number) # Variable for storing the power power = 0 # The loop executes till the number is zero while binary_number != 0: # The remainder of division by 10 allows us to receive the last digit of a number last_digit = binary_number % 10 # Multiplying digit by 2 raised to the relevant power result = last_digit * pow(2, power) # Adding the result to the current decimal number receive the decimal one decimal_number = decimal_number + result # Decreasing decimal number using integer division by 10, allows getting rid of the last digit binary_number = binary_number // 10 # Increasing power by 1 power = power + 1 # Printing the result print("The number in decimal numeral system is:", decimal_number)
Task
It's time to hone in on your skills! Convert a number from binary numeral system to decimal one and print the result. You should follow the algorithm on the right and fill the gaps. As the result, you will receive one of the magic numbers. But the explanation is waiting for you at the end of the chapter.
- Define the variable
power
and assign0
to it. - Count the remainder of division
binary_number
by10
. - Multiply
last_digit
by the2
raised to the relevant power. - Add the
result
to adecimal number
. - Increase
power
by1
. - Print the
decimal_number
.
Note
I guess that you received 1729 and want to know why I claimed that this number is magic? Everything is completely clear: It is called Hardy-Ramanujan number after an anecdote about one of British mathematician G.H Hardly. If you find this information gripping you can read about the anecdote in 'The Man Who Knew Infinity by Robert Knaigel. It is the smallest number that you can express like the sum of two different cubes in two different ways. 1729 can be calculated as the sum of the cubes of 10 and 9, a cube of 10 is 1000 also the cube of 9 is 729, and the sum of the cubes of 12 and 1.
Thanks for your feedback!
Get Acquainted with Binary Code
I guess you got wind of the fact that computers see your code differently than you: this bright machine can read binary code, which consists of 0 and 1. The binary code looks like this 00011100, but zeros in forwarding positions are optional, so you can remove it and write the code like 11100. It is easy for a computer, but a challenge for humans; therefore, you are going to get familiar with deciphering it:
Rule
Here you should do the same operations as in the previous chapter. Find the index of a number(it still begins from the right ) and then multiply the current number by 2 raised to the power of the index. For instance 101
->1x2^2
+ 0x2^1
+ 1x2^0
= 4
+ 0
+ 1
= 5
.
Usage of binary system
The main point of using binary code is that a computer consists of billion transistors that respond to binary signals 0
or 1
; hence, "computer words" that include only 0 and 1 send signals to transistors, 1
means on, and 0
means off.
# Defining binary number binary_number = 1010111 #creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in binary numeral system is:", binary_number) # Variable for storing the power power = 0 # The loop executes till the number is zero while binary_number != 0: # The remainder of division by 10 allows us to receive the last digit of a number last_digit = binary_number % 10 # Multiplying digit by 2 raised to the relevant power result = last_digit * pow(2, power) # Adding the result to the current decimal number receive the decimal one decimal_number = decimal_number + result # Decreasing decimal number using integer division by 10, allows getting rid of the last digit binary_number = binary_number // 10 # Increasing power by 1 power = power + 1 # Printing the result print("The number in decimal numeral system is:", decimal_number)
Task
It's time to hone in on your skills! Convert a number from binary numeral system to decimal one and print the result. You should follow the algorithm on the right and fill the gaps. As the result, you will receive one of the magic numbers. But the explanation is waiting for you at the end of the chapter.
- Define the variable
power
and assign0
to it. - Count the remainder of division
binary_number
by10
. - Multiply
last_digit
by the2
raised to the relevant power. - Add the
result
to adecimal number
. - Increase
power
by1
. - Print the
decimal_number
.
Note
I guess that you received 1729 and want to know why I claimed that this number is magic? Everything is completely clear: It is called Hardy-Ramanujan number after an anecdote about one of British mathematician G.H Hardly. If you find this information gripping you can read about the anecdote in 'The Man Who Knew Infinity by Robert Knaigel. It is the smallest number that you can express like the sum of two different cubes in two different ways. 1729 can be calculated as the sum of the cubes of 10 and 9, a cube of 10 is 1000 also the cube of 9 is 729, and the sum of the cubes of 12 and 1.
Thanks for your feedback!
I guess you got wind of the fact that computers see your code differently than you: this bright machine can read binary code, which consists of 0 and 1. The binary code looks like this 00011100, but zeros in forwarding positions are optional, so you can remove it and write the code like 11100. It is easy for a computer, but a challenge for humans; therefore, you are going to get familiar with deciphering it:
Rule
Here you should do the same operations as in the previous chapter. Find the index of a number(it still begins from the right ) and then multiply the current number by 2 raised to the power of the index. For instance 101
->1x2^2
+ 0x2^1
+ 1x2^0
= 4
+ 0
+ 1
= 5
.
Usage of binary system
The main point of using binary code is that a computer consists of billion transistors that respond to binary signals 0
or 1
; hence, "computer words" that include only 0 and 1 send signals to transistors, 1
means on, and 0
means off.
# Defining binary number binary_number = 1010111 #creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in binary numeral system is:", binary_number) # Variable for storing the power power = 0 # The loop executes till the number is zero while binary_number != 0: # The remainder of division by 10 allows us to receive the last digit of a number last_digit = binary_number % 10 # Multiplying digit by 2 raised to the relevant power result = last_digit * pow(2, power) # Adding the result to the current decimal number receive the decimal one decimal_number = decimal_number + result # Decreasing decimal number using integer division by 10, allows getting rid of the last digit binary_number = binary_number // 10 # Increasing power by 1 power = power + 1 # Printing the result print("The number in decimal numeral system is:", decimal_number)
Task
It's time to hone in on your skills! Convert a number from binary numeral system to decimal one and print the result. You should follow the algorithm on the right and fill the gaps. As the result, you will receive one of the magic numbers. But the explanation is waiting for you at the end of the chapter.
- Define the variable
power
and assign0
to it. - Count the remainder of division
binary_number
by10
. - Multiply
last_digit
by the2
raised to the relevant power. - Add the
result
to adecimal number
. - Increase
power
by1
. - Print the
decimal_number
.
Note
I guess that you received 1729 and want to know why I claimed that this number is magic? Everything is completely clear: It is called Hardy-Ramanujan number after an anecdote about one of British mathematician G.H Hardly. If you find this information gripping you can read about the anecdote in 'The Man Who Knew Infinity by Robert Knaigel. It is the smallest number that you can express like the sum of two different cubes in two different ways. 1729 can be calculated as the sum of the cubes of 10 and 9, a cube of 10 is 1000 also the cube of 9 is 729, and the sum of the cubes of 12 and 1.