You are viewing our Forum Archives. To view or take place in current topics click here.
Can somebody do me a big favour?
Posted:

Can somebody do me a big favour?Posted:

TotalTrigger
  • Rising Star
Status: Offline
Joined: Apr 30, 201112Year Member
Posts: 710
Reputation Power: 28
Status: Offline
Joined: Apr 30, 201112Year Member
Posts: 710
Reputation Power: 28
I've asked on here before and somebody was a real help, wondering if somebody could do the same again.

Basically I'm in a stuck position because I have no clue what to do.

What I need to construct is a ASCII to Binary in Python.

Here are the task:

'You only need to do decimal 32 to decimal 122. You don't need to work out the Hex column, the only columns you need are the decimal and the Ascii. The program should work so if the person enters the binary number for 33 which would be 00100001 then an exclamation mark would be displayed.'

If anyone could do this it would be so much help!.

Thanks and will give REP.
#2. Posted:
Clunge
  • 2 Million
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 1,095
Reputation Power: 202
Status: Offline
Joined: Dec 31, 200914Year Member
Posts: 1,095
Reputation Power: 202
TotalTrigger wrote I've asked on here before and somebody was a real help, wondering if somebody could do the same again.

Basically I'm in a stuck position because I have no clue what to do.

What I need to construct is a ASCII to Binary in Python.

Here are the task:

'You only need to do decimal 32 to decimal 122. You don't need to work out the Hex column, the only columns you need are the decimal and the Ascii. The program should work so if the person enters the binary number for 33 which would be 00100001 then an exclamation mark would be displayed.'

If anyone could do this it would be so much help!.

Thanks and will give REP.


This should be very trivial providing you are allowed to use in-built functions. I haven't coded in Python for a long time, so this may be syntactically incorrect, but it should be pretty close if not correct.



decimal = raw_input("Enter decimal: ")
ascii = chr(decimal)

print ascii


To convert a decimal to its ASCII character use 'chr' and to convert an ASCII character into a decimal use 'ord'. However, you mentioned binary numbers in your post, which is a little ambiguous, is a little bit more complicated so let me know if you want this as wel;.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.