Python: Printing a variable in a function

时间:2017-08-30 20:46:37

标签: python function

First timer here. I'm learning Python but struggle not seeing results when I do the exercises (specifically when I use, return). Not seeing the output is hindering how I learn. Anywho. I am trying to print out variables in the below functions to visual what's going one.

Additionally, I think I'm confused with the functions here. For instance, with the get_average function, I'm not understanding the connection to the dictionaries. I am assuming they are supposed to tie back to one another, correct? Or am I incorrect in thinking they should tie together?

Thanks!

OpenCVWrapper

2 个答案:

答案 0 :(得分:2)

What you are doing in your code, is declaring variables and defining functions. Nothing is being run yet. What you need to do is call those functions, and print them (if you want to see the results). Try appending that to your script:

ActiveX Data Objects 2.8 Library

or

Interop.ADODB.DLL size: 100K Ver 2.0.0.0

答案 1 :(得分:0)

your average function gets a list of grades sum them, then it returns the average as a float.

your get_average function gets a student in the dictionary, calls the average three times once for homework average, once for quizzes and once for tests, and returns an average in which tests weigh more and etc.

in order to get a student's average all you have to do is to call the function from main() with the student whose average you need to calculate.