Intro to
Computer
Science

Spring 2021
course
site
-->

March 18

... start recording

Questions about anything?


First discuss the homework due today .

One more like this in breakout rooms : 20min

The value of a name is determined by summing up the values of the letters of the 
name where 'a' is 1, 'b' is 2, 'c' 3 etc., up to 'z' being 26. For example, the 
name "Zelle" would have the value 26+5+12+12+5=60. Write a program that 
calculates the numeric value of a single name provided as input.

Have one person (the driver) do the typing in an editor, and the other person (the navigator) look up documentation and think about what's going on. (BTW, this technique is called pair programming.)

Create a python program name_value.py . Your program will need to do these things within the main function :

* ask the user for a name
* convert the name to lower case
* initialize an accumulator variable to hold the result to 0
* loop over the letters in the name
*     convert the letter to a number (using `ord()`); adjust so `a` is 1.
*     add that to the acculumator 
* print out the result

Then move on to start to discuss this week's new material, in chapter 6 : functions. I'll post the assignment later today, due next Wednesday, and we'll discuss on Monday.

Please do read chapter 6 before Monday, and start to look at the assignment exercises.

https://cs.bennington.college /courses /spring2021 /introcs /notes /march18
last modified Wed March 17 2021 9:16 pm