More Arithmetic, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
More Arithmetic in one minute
What students need to know
After importing math, you access its contents with math.pi or math.sqrt(). random.randint(1, 10) returns a random integer from 1 to 10 inclusive.
import gives your program access to extra functions in an external module. Convention is to put all imports at the top so they're easy to find.
Mistakes students make
- Module name is lowercase: import random, not import Random.
- Must use dot notation random.randint(), not just randint().
- randint() needs two arguments: the start and end numbers.
- sleep() takes a number, not a string: use 3, not '3'.
What students will learn in this module
Every question in Module 18
Quick questions
- What does import do?ALoads a module so you can use itBPrints text
- Where should import go in your code?AAt the bottomBAt the top of the file
- What does random.randint(1, 6) return?AA random number from 1 to 6BAlways 1
- What does time.sleep(3) do?APauses for 3 secondsBPrints 3
- What happens if you use random.randint() without import?AReturns 0BNameError
Key terms
Students type the meaning of:
importModulerandomtime
Match the pairs
randint(1, 6)Match it to what it doesimport RandomMatch it to what it doesimport math print(math.pi)Match it to what it does
import random random.randint(1, 10)Match it to what it does
import math print(math.sqrt(25))Match it to what it does
import math print(math.floor(3.9))Match it to what it does
Fill in the blanks
______ random print(random.randint(1, 10))
import random print(random._______(1, 6))
import ____ time.sleep(2)
import random print(random.______(colors))
import time time._____(3)
Spot the error
Question 1
Aimport RandomBlow = 1Chigh = 10Dresult = Random.randint(low, high)Eprint(result)
Question 2
Aimport randomBlow = 1Chigh = 10Dresult = randint(low, high)Eprint(result)
Question 3
Aimport randomBlow = 1Chigh = 10Dresult = random.randint(low)Eprint(result)
Question 4
Aimport timeBprint('Starting...')Ctime.sleep('3')Dprint('3 seconds later...')Eprint('Done!')
Question 5
Aimport random()Blow = 1Chigh = 6Dresult = random.randint(low, high)Eprint('Dice roll:', result)
