Quantcast
Channel: Programming Help Forums / Other Languages / Python
Viewing all articles
Browse latest Browse all 11

help me on a python program?

$
0
0
The ascii equivalent of the decimal number 0 is 00000000, while the ascii equivalent of 255 is 11111111. To convert from decimal to ascii, first divide the decimal number by 128. If it divides once, the first ascii digit is 1. Otherwise, it is 0. Then divide the remainder by 64 to get the second digit in the ascii code. Keep dividing the remainders by half the preceding amount to get each digit in your ascii number. You need to do this division eight times (for the eight digits in your ascii byte) until you divide by 1 to get your last ascii digit.
You are to write a program that calculates the ascii numbers when given any decimal number between 0 and 255. The program is to contain a function call deciToAscii(number) that accepts the decimal argument and returns an ascii number as an eight character string.

Viewing all articles
Browse latest Browse all 11

Trending Articles