DS 1501 · Lesson 11 of 24
Instructor: Corey Schafer13m
Sign in to watchLeverage Python's built-in utility functions and the random module to simulate stochastic experiments, sampling, and Monte Carlo checks. What you will learn: • Essential built-ins for Data Science: abs(), round(), pow(), sum(), min(), max(), sorted(), len(), any(), all(), chr(), ord(). • Understanding inclusive vs exclusive bounds in the random module: - random.random() -> [0.0, 1.0) - random.randint(a, b) -> [a, b] (BOTH ends inclusive!) - random.randrange(start, stop, step) -> stop exclusive (like range) - random.choice(seq), random.sample(seq, k), random.shuffle(lst). • Reproducible Data Science experiments via random.seed(42). University Outline Mapping: Class 11 · CO3 · Reading: 2.9, 3.17, 4.4 (deitel) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 11 | CO3 | Reading: Deitel 2.9, 3.17, 4.4 High-Value Distinctions for Exams: • randint(1, 6) CAN return 6; randrange(1, 6) CANNOT return 6! • round(2.5) -> 2 and round(3.5) -> 4 in Python 3 (banker's round-half-to-even). • random.shuffle(lst) mutates lst in place and returns None; random.sample(lst, k) returns a new list. • Watch Corey Schafer's Modules tutorial in Further reading for import forms.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community