1321 lecture Module 4

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:33 PM on 6/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

19 Terms

1
New cards

True or False: your computer cannot give you a truly random value, hence we call it a pseudo-random generator.

True

2
New cards

If you know the ____ ____, you can determine the predict the random sequence.

initial seed

3
New cards

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*)

4
New cards

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

5
New cards

random Module: What is randrange(), how many parameters, and what do they do?

randomly generates range, otherwise works exactly range, parameters: (start, stop, step)

6
New cards

random Module: What is randint(), and are the values inclusive?

takes take integers, and returns random integer between values, values are inclusive.

7
New cards

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,

8
New cards

time Module:time()

It return the number of seconds since January 1st, 1970, 00:00:00 UTC (Unix Epoch)

9
New cards

time Module: ctime()

Takes in as argument a number of seconds and returns a more readable date and time format.

10
New cards

math Module: ceil()

This function takes in one numerical parameter, and it returns the smallest integer greater than or equal to the parameter value.

11
New cards

math Module: floor()

This function takes in one numerical parameter, and it returns the smallest integer less than or equal to the parameter value.

12
New cards

math Module: fabs()

This function takes in one numerical parameter, and it returns the absolute value of the parameter.

13
New cards

math Module: sqrt()

returns the square root of the parameter

14
New cards

math Module: cbrt()

returns the cube root of the parameter

15
New cards

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).

16
New cards

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”

17
New cards

os Module: getcwd()

This function does not take any parameters. It returns a string representing the current working directory.

18
New cards

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.

19
New cards

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.