01. Perform Operations using Modules and Tools 1 Flashcards

1
Q

What will be the output of the following program?

A
  1. 3.141592653588973
  2. 45
  3. 44
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain how the date and time is retrieved and assigned to the variable

import datetime

todayWithTime = datetime.datetime.today()

A
  1. First, the datetime module is imported.
  2. Then, the variable is given a value but using the following in this order.
  3. Access the datetime class
  4. Access the datetime module
  5. Use the built-in today function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Provide one example as to why you would use the “import io” module

A

You would use the import io module if you wished to work with reading and writing to files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What module must be imported for this piece of code to work correctly?

A
  1. The module to import would be “import sys”
  2. This module will display system information along with errors messages such as “ZeroDivisionError”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If you wished to create a folder, what module would you import?

A

import os

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What import statement would you use to generate a random integer value?

A

from random import randint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When using the import datetime module, what does the function “strptime” do?

A

This function takes a string and converts it to a date.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which functions can be used from the math module? (Select all correct answers.)

Select one or more:

a. log
b. tan
c. radians
d. isinf
e. sin
f. floor
g. atan
h. isfinite
i. con
j. acos
k. log10
l. gcd
m. ceil
n. cosh
o. pow
p. asin
q. isnan
r. sqrt
s. degrees
t. pro
u. cos
v. factorial

A

a. log
b. tan
e. sin
f. floor
m. ceil
o. pow
r. sqrt
u. cos

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

os.path is used to perform which action?

Select one:

a. Help find files and folders on specific paths
b. Display operating pathways
c. Configure files on the OS level
d. Run complex routines on known paths

A

a. Help find files and folders on specific paths

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The datetime class can be used to build a ________________

a: random library
b: number generator
c: database
d: date calculation

A

d: date calculation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The sys module is used to perform which function?

Select one:

a. Allows users to log into a system
b. Gives the user access to display and process system information
c. Gives users access to system configurations
d. Turns the Python system on or off

A

b. Gives the user access to display and process system information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which code entry, when used with the random module, can be used to generate a random number between one and ten?

Select one:

a. rand_num = randint(1,10)
b. rand_num = randint(0,11)
c. rand_num = randnum(1,11)
d. rand_num = randint(0,10)
e. rand_num = randNum(1,11)

A

a. rand_num = randint(1,10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly