Professional Documents
Culture Documents
Reference Sheet MIDTERM
Reference Sheet MIDTERM
Usage Explanation
s.replace(old, new) returns copy of s with every occurrence of old replaced with new
Page 1 of 7
List operators and functions
List methods
Page 2 of 7
Dictionary methods
Set methods
Page 3 of 7
Operator Precedence
Page 4 of 7
function definition syntax
range() function
File Input/Output
Module random
random.randrange() : takes a pair of integers a and b, and returns some number between a and b-1
random.uniform(): takes two numbers a and b, and returns a float number x such that a <= x <= b
random.sample(): takes an input the container and an integer k, and returns a list of k items in the
container
Page 5 of 7
Try-except syntax
Page 6 of 7
Page 7 of 7