1/54
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
math.sqrt(x)
Square root.
math.ceil(x)
Round up to nearest integer.
math.floor(x)
Round down to nearest integer.
math.trunc(x)
Chop off the decimal, keep integer part.
math.fabs(x)
Absolute value (always float).
math.fmod(x, y)
Remainder of division (x % y but works better for floats).
math.isqrt(x)
Integer square root (no decimals).
math.isnan(x)
Checks if value is NaN ("not a number").
math.pow(x, y)
Raises to power, returns float.
math.pi
Constant π (3.14159...).
datetime.datetime.now()
Current local date & time.
datetime.datetime.today()
Same as now().
datetime.date.today()
Current date only.
datetime.datetime.strftime(format)
Format datetime → string.
datetime.datetime.strptime(string, format)
Parse string → datetime.
.year
Attribute for the year.
.month
Attribute for the month.
.day
Attribute for the day.
.hour
Attribute for the hour.
.minute
Attribute for the minute.
.second
Attribute for the second.
.weekday()
0=Monday ... 6=Sunday.
.isoweekday()
1=Monday ... 7=Sunday.
datetime.timedelta
Represents difference in time.
random.random()
Float between 0.0 and 1.0.
random.randint(a, b)
Random int between a and b (inclusive).
random.randrange(start, stop, step)
Like range() but random pick.
random.choice(seq)
Random element from sequence.
random.sample(population, k)
Random k unique elements.
random.shuffle(list)
Shuffle list in place.
random.randint(1, 6)
Generates a random integer between 1 and 6, inclusive.
random.randrange(0, 10, 2)
Generates a random even integer from the range 0 to 10.
random.choice(['a','b','c'])
Selects a random element from the list.
random.sample(range(10), 3)
Selects 3 unique random elements from the range 0 to 9.
os.getcwd()
Returns the current working directory.
os.listdir(path='.')
Lists files in the specified directory, default is current directory.
os.mkdir(name)
Creates a new directory with the specified name.
os.rmdir(name)
Removes an empty directory with the specified name.
os.remove(filename)
Deletes the specified file.
os.path.exists(path)
Checks if the specified file or folder exists.
os.path.join(a, b)
Safely joins two path components.
sys.version
Returns the Python version string.
sys.platform
Returns the OS name (e.g., 'win32', 'linux', 'darwin').
sys.argv
List of command-line arguments passed to the script.
sys.exit(n)
Exits the program with the specified status code (0 = success).
io.StringIO()
Creates an in-memory text stream that acts like a file.
io.BytesIO()
Creates an in-memory binary stream.
unittest.TestCase.assertEqual(a, b)
Checks if a is equal to b.
unittest.TestCase.assertNotEqual(a, b)
Checks if a is not equal to b.
unittest.TestCase.assertTrue(x)
Checks that x is True.
unittest.TestCase.assertFalse(x)
Checks that x is False.
unittest.TestCase.assertIs(a, b)
Checks if a is b.
unittest.TestCase.assertIsNot(a, b)
Checks if a is not b.
unittest.TestCase.assertIsInstance(obj, cls)
Checks if obj is an instance of cls.
unittest.TestCase.assertIn(a, b)
Checks if a is in b.