Question: The following shall be written in python code. Please help develop it according to the specifications below. Note that the appendix shows the sample output.
The following shall be written in python code. Please help develop it according to the specifications below. Note that the appendix shows the sample output.



Implement a program in file Task2.py that provides a menu to convert positive integers from decimal representation into hexadecimal and binary. Your menu should use 1 for converting a number in decimal representation to binary, 2 for converting to hexadecimal, and 3 for quitting. For options 1 and 2 it should also print the result. As usual, make sure you use good code layout, with consistent and meaningful variable names, well commented, and you modularise if appropriate. i Information The algorithm to convert an integer n to binary has the following steps: divide n by 2 (integer division) take the reminder repeat above two steps until the result of the division is 0. The binary value is then the sequence of reminders from last to first. See this appendix for an example and some sample output Appendix 2 Example of a decimal number (18) to binary: first divide 18 by 2, obtaining 9 with remainder 0; then divide 9 by 2, obtaining 4 with reminder 1; then divide 4 by 2, obtaining 2 with reminder 0; then divide 2 by 2, obtaining 1 with reminder 0; then divide 1 by 2, obtaining with reminder 1. Since we obtained 0, the loop finishes, returning the string "10010" as the binary representation of decimal number 18. Sample output: Menu 1. Decimal to Binary 2. Decimal to Hexadecimal 3. Quit Enter command: 1 Enter number to be converted 2 10 Menu... Enter command: 1 Enter number to be converted 15 1111 Menu... Enter command: 2 Enter number to be converted 16 10 Menu... Enter command : 2 Enter number to be converted 1234 4D2 Menu... Enter command: 3 Maria-new : Week1 mbandas
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
