This week’s challenge is all about Binary numbers. In particular, we are looking at developing a program which will ask a user to convert between Binary (Base 2) and Decimal (Base 10) numbers.
Develop a program which will output a random 8-bit binary number. Your program should then ask the user to convert the number into decimal. Inform the user whether they have guessed correctly or incorrectly.
You are converting from binary to decimal. The binary number is: 10010011 Please enter this number as a decimal number:
Extend your program so that it may instead randomly output a decimal number between 0-255. Your program should ask the user to convert this decimal number into binary. Inform the user whether they have guessed correctly or incorrectly.
You are converting from decimal to binary. The decimal number is: 56 Please enter this number as an 8-bit binary number:
Extend your program further so that the user is repeatedly asked questions until they answer incorrectly. The user’s score should be tracked, and the highest score should be stored in a text file.
Modify your program so that it ignores any leading zeros in a user’s input. For example: a user should be able to represent 13 as 1101, 01101, 001101, 00001101 etc.