Binary and Positional number systems accepted answer does not match the instructions

The instructions ask the user to assign variables for the weight and value of digit 5 in the number 645231. Counting from the left starting with 0, digit 5 is equal to 6 and it is in the
hundred thousands place, so its weight is 10^5 or 100,000 and its value is 600,000.

The accepted answer is looking for a weight of 1,000 and the digit 5 for a value of 5,000. That would be correct if the instructions asked for weight and value of digit 3 instead.

Screen Link:

My Code:

weight_digit_5 = 10 ** 5
value_digit_5 = 6 * weight_digit_5

What I expected to happen:

What actually happened:

weight_digit_5int (<class 'int'>)
- actual + expected

- 100000
+ 1000

value_digit_5 int (<class 'int'>)
- actual + expected

- 600000
+ 5000
1 Like

Hello @michael.mccarthy. Welcome to the DQ community!

I think you got confused with the counting. The counting starts from the right to the left - beginning from 0. So, for the value 645231, the digit 5 will have a weight of 10^3 and value_digit_5 would be weight_digit_5 * 5

I think you mean “from the right starting with 0”. And if you mean this, it’s still wrong. The instructions aren’t asking for the weight and value of the digits at position 5. They’re asking for the weight and values of the digit 5, which is at position 3 starting from 0 and counting from the right.

This is a well designed exercise because it allows you get it right (coincidentally) for digit 2, but it catches you if you confuse the concepts :slight_smile:

2 Likes