CS 110 Lecture 5: CS 110 Lesson 5 notes
Document Summary
Parse error/syntax error: writing code incorrectly, such as forgetting a colon or parenthesis. Type error: the value that is put into a variable cannot work with the function called. Example: range(1. 5,10. 5: will cause a type error because the range() function only takes integers as parameters. Name error: trying to use a variable that doesn"t exist or doesn"t have a value yet. Data error: the data itself is messed up. Not necessarily the wrong type, just a logical error: example: trying to divide by 0. The shell will tell you where the error is located, and is correct for the most part: The syntax for creating functions is to start the function with def. Function names are put in camel case def rangeenhanced(): Function header contains the name and parameters def rangeenhanced(start,end,step): All the code within a function must be indented in python. Anything indented along the same line is called a code block.