Stock Bots
- Automated Trading System - 75% of stock trades are bots
- Crash of 2:45
Practice Session
- Saturday at 5PM in Trexler 363
- CS subject tutor will give you practice problems answer any questions you have
Reading Questions
Quiz
Modules
- We already know how to use modules, we’ve been using them since the first Python program you created
- When you add import turtleto the top of a file it allows you to use functions that begin with turtle dot something
- It allows you to use code that someone else wrote
- For example write a program like the following - pi = 3.14159 print('I created the variable pi.')
- Save it as import_me.py
- Create another program - import import_me print('I imported the variable pi.') print('And now I can print it.' print(import_me.pi)
- Importing another pythong file, executes all of the code in it
- This includes creating any of the variables that are defined in it as well as any of the functions in it
- We haven’t learned how to define our own functions yet, but you have used functions that you have imported with turtle, turtle.forward(100), for example
- Note, that to use the variable in the module, it must be prefixed with the name of the module
- This is why all the turtle functions start with turtle.
- This is also why you can’t name a file the same thing as one of the modules you are importing 
Math Module
- One useful module is the math module, which gives you functions like math.sin,math.cos,math.log
- In addition to functions, modules can have variable you can use
- The math module has math.piso you don’t have create a constant
Random Module
- Another useful module is the random module, which give you functions to generate pseudo-random numbers
- The random.randomfunction gives random numbers in the range [0.0, 1.0) (note that is exclusive of 1.0)
- The random.randrangefunction give random integers in the specified range (note the upper bound is exclusive)
- The probablity distribution of both random functions is flat
- What if you want to create a floating point number in a range?