Answer to Question #240252 in Python for rai

Question #240252

Example Output:

Welcome to the Binary/Hexadecimal Converter App


Compute binary and hexadecimal values up to the following decimal number: 12

Generating lists....complete!


Using slices, we will now show a portion of each list.

What decimal number would you like to start at: 4

What decimal number would you like to stop at: 7


Decimal values from 4 to 7:

4

5

6

7


Binary values from 4 to 7:

0b100

0b101

0b110

0b111


Hexadecimal values from 4 to 7:

0x4

0x5

0x6

0x7


Press Enter to see all values from 1 to 12.

Decimal --- Binary --- Hecadecimal


1----0b1----0x1

2----0b10----0x2

3----0b11----0x3

4----0b100----0x4

5----0b101----0x5

6----0b110----0x6

7----0b111----0x7

8----0b1000----0x8

9----0b1001----0x9

10----0b1010----0xa

11----0b1011----0xb

12----0b1100----0xc1. Binary Hexadecimal Converter App





1
Expert's answer
2021-09-22T00:00:18-0400
print('Welcome to the Binary/Hexadecimal Converter App')
mx = int(input('Compute binary and hexadecimal values up to the following decimal number: '))
print('Generating lists....complete!')
print('Using slices, we will now show a portion of each list.')
frm = int(input('What decimal number would you like to start at: '))
to = int(input('What decimal number would you like to stop at: '))
print()
print(f'Decimal values from {frm} to {to}:')
print(*range(frm, to + 1), sep='\n')
print()
print(f'Binary values from {frm} to {to}:')
print(*[bin(x) for x in range(frm, to + 1)], sep='\n')
print()
print(f'Hexadecimal values {frm} to {to}:')
print(*[hex(x) for x in range(frm, to + 1)], sep='\n')
print()
input(f'Press Enter to see all values from 1 to {mx}.')
print('Decimal --- Binary --- Hecadecimal')
for i in range(1, mx + 1):
    print(f'{i}----{bin(i)}----{hex(i)}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS