Week 7 Notes
Week 7 Notes CS 1110-002
Popular in Intro to Computing using Python
verified elite notetaker
Popular in ComputerScienence
This 2 page Class Notes was uploaded by Eunice on Saturday March 12, 2016. The Class Notes belongs to CS 1110-002 at Cornell University taught by Lee, Van Loan in Spring 2016. Since its upload, it has received 18 views. For similar materials see Intro to Computing using Python in ComputerScienence at Cornell University.
Reviews for Week 7 Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 03/12/16
CS 1110 Van Loan and Lee Spring 2016 March 8, 2016 if the variable that is assigned to another is updated, the other variable doesn’t update with it while loop o open ended iteration o refining the sqrt for loop will execute for the number of times you input while loop will execute until it is at a specified error margin o up/down sequence given a number n if even, replace by its half if odd, replace by 3n+1 will you always end up at 1 o with open-ended, it is possible that the loop won’t end infinite loop insert a condition to end the loop after a certain number of steps given that it hasn’t ended on its own March 10, 2016 logical maneuvers o loop body returns o logical maneuvers make codes more user friendly corrects and points out errors importerror o importing something that doesn’t exist nameerror o a variable hasn’t been defined typeerror o ex. dividing a string by an integer zerodivisionerror o can’t divide by zero assertions ability to generate exceptions “assert [Boolean expression],[string]” o is Boolean is not true then string is printed and an exception is made type checking o use assert and the function isinstance o ex. isinstance(x,int) if x houses an int then It’s true check for strings and floats too try-except construction try: o code that may generate a particular exception except [name of exception]: o code to execute if specified exception is found break a way to terminate a loop