01. Perform Operations using Modules and Tools 1 Flashcards
What will be the output of the following program?
- 3.141592653588973
- 45
- 44
Explain how the date and time is retrieved and assigned to the variable
import datetime
todayWithTime = datetime.datetime.today()
- First, the datetime module is imported.
- Then, the variable is given a value but using the following in this order.
- Access the datetime class
- Access the datetime module
- Use the built-in today function
Provide one example as to why you would use the “import io” module
You would use the import io module if you wished to work with reading and writing to files.
What module must be imported for this piece of code to work correctly?
- The module to import would be “import sys”
- This module will display system information along with errors messages such as “ZeroDivisionError”
If you wished to create a folder, what module would you import?
import os
What import statement would you use to generate a random integer value?
from random import randint
When using the import datetime module, what does the function “strptime” do?
This function takes a string and converts it to a date.
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. log
b. tan
e. sin
f. floor
m. ceil
o. pow
r. sqrt
u. cos
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. Help find files and folders on specific paths
The datetime class can be used to build a ________________
a: random library
b: number generator
c: database
d: date calculation
d: date calculation
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
b. Gives the user access to display and process system information
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. rand_num = randint(1,10)