Thursday, January 20, 2011

The First Python Project for Contemporary College Mathematics

I just finished my first Python project for my Contemporary College Mathematics class.  The goal of the project is to have the students download Python and run one script.  The script takes there name and adds the ASCII values of the characters in their name.  The sum is my way of checking if they did the work.  You can find the instructions on Google Docs here.  The directions are a Microsoft 2010 document that was converted to Google Docs format. 

The script project_1.py is below.  You can download it here, or cut and paste it from this page.

def string_to_sum(in_string):
    sum = 0
    for a in in_string:
        sum = sum + ord(a)
    return sum

in_string = raw_input('Please type your name. ')
sum = string_to_sum(in_string)
print 'Thank you,', in_string, '.  Your output number is', sum

temp = raw_input('Press Enter to exit.')