Question 1

Question 2
Question 3
Question 4
Question 5
A)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 attent
readability
maintainability
scalability
portability
A)Software adheres to the standards of privacy if it(1 point)
uses code that is encrypted before being merged into the project tree.
protects client data against unauthorized access and use.
protects the system from hacking.
is independent of platforms and systems, or can be easily adapted.
A)Which of the following aspects can make your code reusable?(1 point)
adding print statements
adding required functionalities
adding comments
adding functions
A)What is meant by functional code?(1 point)
The code can handle a huge number of users at the same time.
The code can be used, with little modifications for different software.
The code is working and performing the required functionalities.
The code has a good number of comments.

A)
Evaluate the code below, and suggest ways to improve it.
def find_sum(num1, num_2):
'''
Finds and returns sum of two numbers
'''
return num1 + num_2

The method has a docstring that is not descriptive enough. The docstring should mention the variables and their descriptions to improve the code.
Instead of returning the sum, the program should just print it onscreen.
There should be an additional variable defined at the beginning to store the sum, and this value is returned at the end.
The name of this method should be something else.

1 answer

Here are the responses to your questions and evaluation of the provided code:

  1. Attribute of code development that students want to pay attention to for creating a platform-independent application:

    • Portability: This is the attribute that allows software to be easily transferred and run on different platforms without requiring major modifications.
  2. Description of software adhering to the standards of privacy:

    • Protects client data against unauthorized access and use: This definition highlights the importance of safeguarding private data, which is a key aspect of privacy standards in software.
  3. Aspect that can make your code reusable:

    • Adding functions: Organizing code into functions makes it modular, allowing the same functions to be reused in different parts of a program or in different programs altogether.
  4. Meaning of functional code:

    • The code is working and performing the required functionalities: This is the correct understanding of functional code, which emphasizes that the code should fulfill its intended purpose effectively.
  5. Evaluation and suggestions to improve the provided code:

def find_sum(num1, num2):
    '''
    Finds and returns the sum of two numbers.

    Parameters:
    num1 (int/float): The first number to be added.
    num2 (int/float): The second number to be added.

    Returns:
    int/float: The sum of num1 and num2.
    '''
    return num1 + num2

Suggestions for Improvement:

  • Docstring Enhancements: Make the docstring more descriptive by including details on the parameters and the return value, as shown above.

  • Parameter Naming Conventions: Fix the parameter name from num_2 to num2 to maintain consistency in naming (using underscores in variable names should be uniform).

  • Type Hints: Consider adding type hints in the function signature for better clarity. E.g., def find_sum(num1: float, num2: float) -> float:.

  • Commenting: While the method is small, including comments for complex logic can be beneficial as code complexity increases.

  • Consider Edge Cases: The function could also be improved by adding validation to check the types of inputs to ensure they are numbers.

These improvements would increase the code’s readability, maintainability, and overall quality.