2017-03-02

posted Mar 2, 2017, 4:17 AM by Samuel Konstantinovich   [ updated Mar 2, 2017, 4:38 AM ]
Goal: Character manipulation

HW: By Monday, complete EVERY problem from coding bat under codingbat.com/home/konstans@stuy.edu/all  (before the rot13 category) this includes the extra two that I said you should do later. 
The exception the problems posted on Friday (rot13/rotX category), which are due Tuesday to allow for Dojo time.
Today's new problems will be the character shifting problems.

On the Computer:
1. What is the chr(65)
2. What is the ord('A')
3. Test chr and ord on different values, and come up with an explanation of what they do. Write it on paper!



How can you convert a character to the character after it?

f('a') → 'b'

f('S') → 'T'




Remember you can convert characters to integers and integers to characters using chr() and ord()

Ord gives you the numerical value of a character

ord('a') --> 97  

Chr gives you the character of a numerical value, where the value is between 0 and 255 inclusive.

chr(97) --> 'a'


The number is meaningful, it is the ASCII (as-key) value:

http://www.asciitable.com/

This is why lower case letters are smaller. 



Comments