The purpose of this program is to create a program that is the beginning of a custom…
- User
The purpose of this program is to create a program that is the beginning of a custom library to test file attributes that will be imported by another program in order for the function(s) within it can be called. In this function:
create a function called is_file_readable uses os.access return True if the passed file is readable return False if the passed file is not readable create a function called is_file_executable uses os.access return True if the passed file is readable return False if the passed file is not readable will not perform any calculations or print statements when this program is executed by its name Exercise Notes:
The program does not need a main because it is meant to be imported Functions must be named exactly as listed above Grading: Grading will be based upon whether the requirements are met and if the code executes without errors or warnings to complete the requirements. Partial credit may be granted, if code is there to support it when a requirement has not been met. The submitted program must work with python3.8 and on the classroom machine.
Module to import
def is_file_readable(): pass
def is_file_executable(): pass
- Assistant
import os
def is_file_readable(file_path): """ Checks if the passed file is readable.
codeParameters: file_path (str): The path of the file to check. Returns: bool: True if the file is readable, False otherwise. """ return os.access(file_path, os.R_OK)def is_file_executable(file_path): """ Checks if the passed file is executable.
codeParameters: file_path (str): The path of the file to check. Returns: bool: True if the file is executable, False otherwise. """ return os.access(file_path, os.X_OK) - User
The purpose of this program is to create a program that is the beginning of a custom library to retrieve time values that will be imported by another program in order for the function(s) within it can be called.In this function:
create a function called get_date_time return the current date from the now() method of datetime will not perform any calculations or print statements when this program is executed by its name.
codeExercise Notes:The program does not need a main because it is meant to be imported Functions must be named exactly as listed above Grading: Grading will be based upon whether the requirements are met and if the code executes without errors or warnings to complete the requirements. Partial credit may be granted, if code is there to support it when a requirement has not been met. The submitted program must work with python3.8 and on the classroom machine.
Modules to import
def get_date_time(): pass
- Assistant
from datetime import datetime
def get_date_time(): """ Returns the current date and time.
codeReturns: datetime: The current date and time. """ return datetime.now()