Download presentation
Presentation is loading. Please wait.
Published byMaurice Gaines Modified over 9 years ago
1
LING 408/508: Programming for Linguists Lecture 25 December 2 nd
2
Last Time Monte Carlo Simulation Player A has an unfair advantage!
3
100,000 games
4
1,000,000 games
5
rball2.py Let's make it fair:
6
rball2.py Let's make it fair: swap serves
7
100,000 games
8
1,000,000 games
9
Chapter 10: Defining Classes
10
Chapter 10: MSDie Multi-Sided Die: self is just a conventional name for the implicit 1 st argument to all methods inside the class: could call it anything …
11
Chapter 10: MSDie From last lecture: – library module random
12
Chapter 10: Projectile Cannonball example: – how far does a cannonball fly? – parameters: launch angle height above ground initial velocity – gravity: 9.8 ms -2 – (without calculus) simulation: time interval
13
Chapter 10: Projectile
14
Object-oriented style: – assume a Projectile class: method update()
15
Documentation Triple quoted documentation strings – can span multiple lines help(module) help(module.method) print module.method.__doc__
16
Documentation
17
Chapter 10: Projectile
21
projectile2.py sys.argv list of command line arguments sys.exit(1) quit with exit code 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.