1/18
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
True or False: your computer cannot give you a truly random value, hence we call it a pseudo-random generator.
True
If you know the ____ ____, you can determine the predict the random sequence.
initial seed
By default, this pseudo-randomness is dictated by your _____ _____ ____ as a seed for the random generation.
current system time (usually in milliseconds from the epoch*)
Python uses the ____ _____ which is January 1st, 1970 at 00:00:00 UTC. Therefore, the time (in milliseconds) since that date and time.
Unix Epoch
random Module: What is randrange(), how many parameters, and what do they do?
randomly generates range, otherwise works exactly range, parameters: (start, stop, step)
random Module: What is randint(), and are the values inclusive?
takes take integers, and returns random integer between values, values are inclusive.
random Module: what is choice():
This function takes in a sequence as parameter and will return a randomly selected element in sequence parameter.
Example:
import random
message = "Hello World"
for i in range(10):
print(random.choice(message), end=", ") output: , o, e, H, l, o, l, l, o, o,
time Module:time()
It return the number of seconds since January 1st, 1970, 00:00:00 UTC (Unix Epoch)
time Module: ctime()
Takes in as argument a number of seconds and returns a more readable date and time format.
math Module: ceil()
This function takes in one numerical parameter, and it returns the smallest integer greater than or equal to the parameter value.
math Module: floor()
This function takes in one numerical parameter, and it returns the smallest integer less than or equal to the parameter value.
math Module: fabs()
This function takes in one numerical parameter, and it returns the absolute value of the parameter.
math Module: sqrt()
returns the square root of the parameter
math Module: cbrt()
returns the cube root of the parameter
math Module: log()
This function takes in two numerical parameters, and it returns the logarithm of the first param. to the given base of the second param. (the default base is e).
The math Module contains some useful constant values such as:
pi: The constant value of pi
e: The constant value of Euler’s number (base of the natural logarithm)
inf: positive infinity
nan: “Not a number”
os Module: getcwd()
This function does not take any parameters. It returns a string representing the current working directory.
os Module: mkdir()
This function creates a folder in your computer. It takes in a string parameter representing a path in your system plus the name of the folder. If a path is not given, i.e. you just enter the name of the folder, a new folder will be added in your current working directory.
os Module: listdir()
This function takes in an optional string parameter representing a path in your system, the default value is the current working directory. It returns a list containing the names of the entries in the given path.