CS234 Study Guide - Final Guide: Break Key, Init, Quicksort

175 views20 pages

Document Summary

List slicing: x[:2] takes the first two elements of x x[2:] takes all but the first two element of x. Ex: alist[len(alist) // 2:] + alist[:len(alist) // 2] a= [1,2,3,4,5] len(alist) = 5 5//2 = 2 flipflop(a) [3, 4, 5, 1, 2] Exceptions: an event that can be triggered and optionally handled during program execution. When exception raise an error, program can catch the exception and handle it. When exception is not handled, program will abort an error (ie. indexerror: list out raise an exception when error occurs of range) Typeerror: raised when an incorrect data type is supplied to an operator. Valueerror: raised when is a correct data type but wrong value. Assertionerror (aasert): what we assume to be true at a given point in the program difference between exception and assert: assert can deactivated at run time. Data type: is how to interpret the data.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents