Docsity

WGU D385 CODING LAB 2026/2027 | QUICK FIXES & SOLUTIONS | MOST COMMON CODING ERRORS EXPLA, Exams of Computer Science

Toggle sidebar
bg1
WGU D385 CODING LAB 2026/2027 | QUICK FIXES & SOLUTIONS |
MOST COMMON CODING ERRORS EXPLAINED | PRACTICAL EXAMPLES
| HIGH-YIELD REVIEW GUIDE | CURRENTLY UPDATED
1.
John is a network administrator for ACME company. He is trying to explain
least privileges to a new technician. Which of the following is the basic
premise of least privilege?
Always assign responsibilities to the administrator who has the
minimum permissions required.
When assigning permissions, give users only the permissions they
need to do their work and no more.
Do not give management more permissions than users.
Regularly review user permissions and take away one that they
currently have to see if they will complain or even notice that it is
missing.
2.
If you were to implement a function that checks the quality of user input for a
temperature value, what criteria would you include to ensure its validity?
Check if the value is a boolean.
Check if the value is a list of temperatures.
Check if the value is a string containing letters.
Check
if
the
value
is
a
number within
a
specified
range.
3.
Describe what happens when the assertion for temperature checks fails.
The assertion automatically corrects the temperature value.
The program continues without any interruption.
The assertion prints a warning message without stopping the
program.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download WGU D385 CODING LAB 2026/2027 | QUICK FIXES & SOLUTIONS | MOST COMMON CODING ERRORS EXPLA and more Exams Computer Science in PDF only on Docsity!

WGU D385 CODING LAB 2026/2027 | QUICK FIXES & SOLUTIONS |

MOST COMMON CODING ERRORS EXPLAINED | PRACTICAL EXAMPLES

| HIGH-YIELD REVIEW GUIDE | CURRENTLY UPDATED

  1. John is a network administrator for ACME company. He is trying to explain least privileges to a new technician. Which of the following is the basic premise of least privilege? Always assign responsibilities to the administrator who has the minimum permissions required. When assigning permissions, give users only the permissions they need to do their work and no more. Do not give management more permissions than users. Regularly review user permissions and take away one that they currently have to see if they will complain or even notice that it is missing.
  2. If you were to implement a function that checks the quality of user input for a temperature value, what criteria would you include to ensure its validity? Check if the value is a boolean. Check if the value is a list of temperatures. Check if the value is a string containing letters. Check if the value is a number within a specified range.
  3. Describe what happens when the assertion for temperature checks fails. The assertion automatically corrects the temperature value. The program continues without any interruption. The assertion prints a warning message without stopping the program.

The assertion raises an AssertionError, indicating the temperature is not below freezing.

  1. Describe the importance of logging errors such as division by zero in Python applications. Logging is only important for syntax errors, not runtime errors. Logging errors is unnecessary as they do not affect the program's execution. Logging errors only serves to slow down the application without any benefits. Logging errors like division by zero helps in debugging and maintaining code quality by providing insights into runtime issues.
  2. If a developer receives serialized data that does not pass validation checks, what is the recommended action to take? Automatically fix the data and proceed. Reject the data and raise an error. Ignore the validation and deserialize the data. Log the data and continue processing.
  3. Describe how plain text should be formatted before it is encrypted using AES CTR mode. The plain text should be compressed before encryption. The plain text should be converted to a hexadecimal format. The plain text should be left as a string without any changes. The plain text should be formatted into bytes and padded appropriately.
  1. Describe the importance of implementing data quality checks for strings and numeric values in Python programming. Data quality checks are optional and can be ignored if the code runs without errors. Data quality checks ensure that inputs are valid and meet expected formats, preventing errors and vulnerabilities. Data quality checks are used to improve the aesthetic of the code without affecting functionality. Data quality checks are only necessary for numeric values, as strings are always valid.
  2. A freezer unit for frozen food should maintain temperatures of _____ or below. 24 0 32 10
  3. If you encounter a piece of code that uses the % operator for string formatting and includes a secret key, how would you refactor it to enhance security? Replace the secret key with a hardcoded value. Refactor the code to use f-strings or the format() method to safely include the secret key. Leave the code as is, since it works correctly. Use the % operator but add comments to indicate the risk.
  1. Describe how the least privilege principle can enhance security in a system. By limiting user permissions, the least privilege principle reduces the risk of unauthorized access and potential damage. By providing unrestricted access, it enhances system performance. By granting users full access, it encourages collaboration. By allowing users to access all files, it simplifies user management.
  2. Describe the consequences of failing to validate serialized data before deserialization. Failing to validate serialized data has no significant impact. Failing to validate serialized data improves system efficiency. Failing to validate serialized data only affects performance. Failing to validate serialized data can lead to security vulnerabilities and data corruption.
  3. Why is bcrypt preferred over MD5 for password hashing? MD5 is faster and requires less computational power. MD5 is more widely used in modern applications. Bcrypt is designed to be slow and includes a salt, making it more secure against brute-force attacks. Bcrypt is easier to implement than MD5.
  4. A Custom Object is used to gather feedback about Employees. This Object should be Private so Employees cannot see each other's Records. Only the CEO should see all Records. How can this be done?

Encrypt the plain text without any formatting.

  1. Describe the concept of object-level authorization and its importance in securing data access. Object-level authorization allows any user to access data, promoting transparency. Object-level authorization is irrelevant in modern programming. Object-level authorization restricts data access to the owner, ensuring that sensitive information is protected. Object-level authorization is only necessary for public data.
  2. What method should be used to safely format strings in Python to avoid exposing sensitive information? Concatenate strings using the + operator. Directly print the secret key without formatting. Use f-strings or the format() method instead of the % operator. Use the % operator for string formatting.
  3. Which of the following policies should be used when assigning permissions, giving users only the permissions they need to do their work and no more? Separation of duties Physical access control Acceptable use Least privilege
  4. Format string vulnerabilities arise primarily because: Assumptions are made on the size of the output buffer

More parameters are supplied than the format expects. Invalid parameter values are specified. User input is used as the format specifier.

  1. If you modify the assertion to check for temperatures below freezing and include a custom error message, how would you write it? assert temperature <= 0, 'Temperature is above freezing' assert temperature > 0, 'Temperature must be below freezing' assert temperature == 0, 'Temperature must be below freezing' assert temperature < 0, 'Temperature must be below freezing'
  2. What is the primary purpose of validating incoming serialized data before deserialization? To improve code performance. To ensure data integrity and security. To enhance user interface. To simplify the code structure.
  3. If you have a web application where users can create and manage their profiles, how would you implement object-level authorization to protect user data? By checking the user's identity against the profile owner before granting access. By encrypting all profile data without checking ownership. By using a single access key for all users. By allowing all users to access any profile data.

Blowfish encryption function RSA encryption function

  1. Describe why using the % operator for string formatting can lead to security vulnerabilities in Python. The % operator is the fastest method for string formatting. Using the % operator is recommended for all string operations. The % operator is the only way to format strings in Python. Using the % operator can expose sensitive information if the string is not properly sanitized, allowing for potential injection attacks.
  2. What is the primary method used to ensure that only the owner of an object can access its data in Python? Encrypt the data with AES Apply password hashing Implement object-level authorization Use public access modifiers
  3. Describe how you would implement a range validation check for a numeric input in Python. You can use a loop to continuously prompt for input until a valid number is entered. You can use a try-except block to catch errors when the input is not a number. You can use an if statement to check if the input is greater than or equal to 1 and less than or equal to 10.

You can use a list to store valid numbers and check if the input is in that list.

  1. What happens when your program attempts to divide by zero? Arithmetic exception thrown Garbage will print Nothing will print
  2. What is a correct Python expression for checking to see if a number stored in a variable x is between 0 and 5? x > 0 and < 5 x > 0 or x < 5 x > 0 and x < 5