[Tutor] Digital-to- Roman (pseudocode)

Alan Gilfoy agilfoy at frontiernet.net
Thu Mar 8 23:23:09 CET 2007

Quoting Bob Gailer <bgailer at alum.rpi.edu>:

>> Digital to Roman pseudocode:
>> 1. if digital_input is greater than 1000:
>> subtract 1000 from it and add "M" to string roman_result
>> # How do you do that, add one character to the end of an existing string?
> Start with an empty string:
> roman_result = ""
> To add a character at the end:
> roman_result += "M" # Python shorthand for roman_result = roman_result + "M"
roman_result + "M" would also work, right/ I'm just trying to save  
time on typing in the code, right
>> # also, how do I modify the digital_input variable (it's an integer)
> digital_input -= 1000

is that somewhat like digital_result = digital result - int(1000)?

>> several times through the conversion process?
> You will be processing the input in a loop (while or for).

running = True and
while running

is how I've tended to set

(my pseudocode)

> As you gain familiarity with Python you will develop ways to separate
> data from logic. I might say more about this later, but right now I'm
> about to drive north a bit.
I have already gained some familiary with separating data manipulation  
(data and logic, as a whole) from the code for the user interface,  
that's something that oen of my advisors has been big on.

More information about the Tutor mailing list