Ruotong's Chapter 4 Function Exercise

by Ruotong Yang

28 Jan 2016

Embedded Trinket:

And here is what I’ve done in Chapter 3’s exercise:

I thought in this one, the except is not needed and is not executed. Am I right? But why it is not the same in the above one?

Update: 1. Problem solved. No need to use return in the ‘grade’ function. 2. float() cannot change a string into floating number. We can make use of this feature to separate no input and wrong input
in try/except.

(I’ve already used this in Chapter 3 Exercise, but deepend my understanding this time.)

Ruotong Yang is a master student in STOR department at UNC Chapel Hill. Find Ruotong Yang on Twitter, Github, and on the web.