The attribute of code development that the students would want to pay attention to in order to ensure that their application works on any platform is portability.
Students are creating an application that they want to be able to work on any platform. What attribute of code development would they want to pay attention to?(1 point)
Responses
readability
readability
portability
portability
maintainability
maintainability
scalability
scalability
7 answers
Responses
protects the system from hacking.
protects the system from hacking.
uses code that is encrypted before being merged into the project tree.
uses code that is encrypted before being merged into the project tree.
is independent of platforms and systems, or can be easily adapted.
is independent of platforms and systems, or can be easily adapted.
protects client data against unauthorized access and use.
Software adheres to the standards of privacy if it protects client data against unauthorized access and use.
Responses
adding required functionalities
adding required functionalities
adding functions
adding functions
adding print statements
adding print statements
adding comments
The aspect that can make your code reusable is adding functions.
It looks like you've provided an incomplete code snippet for a function called find_sum
. To evaluate and suggest improvements, I need the full code. However, I can provide some general suggestions about how to improve a typical function for finding the sum of two numbers:
-
Complete the Function: Make sure the function has a complete implementation. You likely want to return the sum of
num1
andnum_2
. -
Parameter Naming: Use consistent and meaningful parameter names. For example, consider renaming
num_2
tonum2
so that it’s consistent withnum1
. -
Docstring Improvement: Enhance the docstring to explain what the function does, its parameters, and its return value.
-
Type Annotations: Include type annotations for the parameters and return value for better clarity and type checking.
-
Input Validation: Add checks to ensure that the inputs are of the correct type (e.g., integers or floats).
Here’s a revised version of the function implementing these suggestions:
def find_sum(num1: float, num2: float) -> float:
"""
Calculate the sum of two numbers.
Parameters:
num1 (float): The first number.
num2 (float): The second number.
Returns:
float: The sum of num1 and num2.
"""
if not isinstance(num1, (int, float)) or not isinstance(num2, (int, float)):
raise ValueError("Both num1 and num2 must be integers or floats.")
return num1 + num2
These changes enhance readability, usability, and robustness.