Python Modules for Certiport IT Specialist Exam: Math, DateTime, Random, OS, Sys, IO, Unittest

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/54

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

55 Terms

1
New cards

math.sqrt(x)

Square root.

2
New cards

math.ceil(x)

Round up to nearest integer.

3
New cards

math.floor(x)

Round down to nearest integer.

4
New cards

math.trunc(x)

Chop off the decimal, keep integer part.

5
New cards

math.fabs(x)

Absolute value (always float).

6
New cards

math.fmod(x, y)

Remainder of division (x % y but works better for floats).

7
New cards

math.isqrt(x)

Integer square root (no decimals).

8
New cards

math.isnan(x)

Checks if value is NaN ("not a number").

9
New cards

math.pow(x, y)

Raises to power, returns float.

10
New cards

math.pi

Constant π (3.14159...).

11
New cards

datetime.datetime.now()

Current local date & time.

12
New cards

datetime.datetime.today()

Same as now().

13
New cards

datetime.date.today()

Current date only.

14
New cards

datetime.datetime.strftime(format)

Format datetime → string.

15
New cards

datetime.datetime.strptime(string, format)

Parse string → datetime.

16
New cards

.year

Attribute for the year.

17
New cards

.month

Attribute for the month.

18
New cards

.day

Attribute for the day.

19
New cards

.hour

Attribute for the hour.

20
New cards

.minute

Attribute for the minute.

21
New cards

.second

Attribute for the second.

22
New cards

.weekday()

0=Monday ... 6=Sunday.

23
New cards

.isoweekday()

1=Monday ... 7=Sunday.

24
New cards

datetime.timedelta

Represents difference in time.

25
New cards

random.random()

Float between 0.0 and 1.0.

26
New cards

random.randint(a, b)

Random int between a and b (inclusive).

27
New cards

random.randrange(start, stop, step)

Like range() but random pick.

28
New cards

random.choice(seq)

Random element from sequence.

29
New cards

random.sample(population, k)

Random k unique elements.

30
New cards

random.shuffle(list)

Shuffle list in place.

31
New cards

random.randint(1, 6)

Generates a random integer between 1 and 6, inclusive.

32
New cards

random.randrange(0, 10, 2)

Generates a random even integer from the range 0 to 10.

33
New cards

random.choice(['a','b','c'])

Selects a random element from the list.

34
New cards

random.sample(range(10), 3)

Selects 3 unique random elements from the range 0 to 9.

35
New cards

os.getcwd()

Returns the current working directory.

36
New cards

os.listdir(path='.')

Lists files in the specified directory, default is current directory.

37
New cards

os.mkdir(name)

Creates a new directory with the specified name.

38
New cards

os.rmdir(name)

Removes an empty directory with the specified name.

39
New cards

os.remove(filename)

Deletes the specified file.

40
New cards

os.path.exists(path)

Checks if the specified file or folder exists.

41
New cards

os.path.join(a, b)

Safely joins two path components.

42
New cards

sys.version

Returns the Python version string.

43
New cards

sys.platform

Returns the OS name (e.g., 'win32', 'linux', 'darwin').

44
New cards

sys.argv

List of command-line arguments passed to the script.

45
New cards

sys.exit(n)

Exits the program with the specified status code (0 = success).

46
New cards

io.StringIO()

Creates an in-memory text stream that acts like a file.

47
New cards

io.BytesIO()

Creates an in-memory binary stream.

48
New cards

unittest.TestCase.assertEqual(a, b)

Checks if a is equal to b.

49
New cards

unittest.TestCase.assertNotEqual(a, b)

Checks if a is not equal to b.

50
New cards

unittest.TestCase.assertTrue(x)

Checks that x is True.

51
New cards

unittest.TestCase.assertFalse(x)

Checks that x is False.

52
New cards

unittest.TestCase.assertIs(a, b)

Checks if a is b.

53
New cards

unittest.TestCase.assertIsNot(a, b)

Checks if a is not b.

54
New cards

unittest.TestCase.assertIsInstance(obj, cls)

Checks if obj is an instance of cls.

55
New cards

unittest.TestCase.assertIn(a, b)

Checks if a is in b.