Docsity

WGU D385 Coding Lab 2026/2027 | Quick Fixes and Solutions | Common Coding Errors Explained, 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 and Solutions | Common Coding Errors Explained 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 fehow fethe feleast feprivilege feprinciple fecan feenhance fesecurity fein fea fesystem. f e By felimiting feuser fepermissions, fethe feleast feprivilege feprinciple fereduces fethe ferisk feof feunauthorized feaccess feand fepotential fedamage. f e f e By f e providing f e unrestricted f e access, f e it f e enhances f e system f e performance. f e f e By fegranting f e users f e full feaccess, f e it f e encourages f e collaboration. f e f e By feallowing f e users feto feaccess feall fefiles, f e it f e simplifies f e user femanagement.
  2. Describe fethe feconsequences feof fefailing feto fevalidate feserialized fedata febefore fedeserialization. f e f e Failing f e to fevalidate f e serialized f e data f e has f e no f e significant f e impact. f e f e Failing f e to fevalidate f e serialized f e data f e improves f e system f e efficiency. f e Failing feto fevalidate feserialized fedata feonly feaffects feperformance. fe Failing feto fevalidate feserialized fedata fecan felead feto fesecurity fevulnerabilities feand fedata fecorruption.
  3. Why feis febcrypt fepreferred feover feMD5 fefor fepassword fehashing? f e MD5 feis fefaster feand ferequires feless fecomputational fepower. f e MD5 feis femore fewidely feused fein femodern feapplications. f e Bcrypt feis fedesigned feto febe feslow feand feincludes fea fesalt, femaking feit femore fesecure feagainst februte-force feattacks. f e Bcrypt feis feeasier feto feimplement fethan feMD5.
  4. A feCustom feObject feis feused feto fegather fefeedback feabout feEmployees. feThis feObject feshould febe fePrivate feso feEmployees fecannot fesee feeach feother's feRecords. feOnly fethe feCEOfeshould feseefeallfeRecords. feHow fecan fethis febefedone?

f e Encrypt fethe f e plain f e text fewithout feany feformatting.

  1. Describe fethe feconcept feof feobject-level feauthorization feand feits feimportance fein fesecuring fedata feaccess. f e Object-level feauthorization feallows feany feuser feto feaccess fedata, fepromoting fetransparency. f e f e Object-level feauthorization f e is f e irrelevant f e in f e modern f e programming. f e Object-level feauthorization ferestricts fedata feaccess feto fethe feowner, feensuring fethat fesensitive feinformation feis feprotected. f e Object-level feauthorization feis feonly fenecessary fefor fepublic fedata.
  2. What femethod feshould febe feused feto fesafely feformat festrings fein fePython feto feavoid feexposing fesensitive feinformation? f e Concatenate festrings feusing fethe fe+ feoperator. f e Directly feprint fethe fesecret fekey fewithout feformatting. f e f e Use fef-strings feor fethe feformat() f e method f e instead f e of f ethe f e % f e operator. f e Use fethe fe% feoperator fefor festring feformatting.
  3. Which feof fethe fefollowing fepolicies feshould febe feused fewhen feassigning fepermissions, fegiving feusers feonly fethe fepermissions fethey feneed feto fedo fetheir fework feand feno femore? f e Separation feof feduties f e Physical feaccess fecontrol f e Acceptable feuse f e Least feprivilege
  4. Format festring fevulnerabilities fearise f e primarily febecause:

f e Assumptions feare femade feon fethe fesize feof fethe feoutput febuffer

  1. What feis fethe feleast feprivilege feprinciple fein fethe fecontext feof fefile fepermissions? f e Allowing feusers feto femodify fefile fepermissions fefreely. f e Granting feall fepermissions feto feall feusers. f e Assigning feonly fethe fepermissions fenecessary fefor feusers feto feperform fetheir fetasks. f e Restricting feaccess feto fefiles febased feon feuser feroles.
  2. If feyou feencounter fea fedivision feby fezero feerror fein fea fePython feapplication, fehow fewould feyoufemodifyfethefecodefetofehandlefethisfesituationfegracefully? f e Change fethe fedivision feoperation feto femultiplication feto feavoid fethe feerror. f e Use fea feconditional festatement feto fecheck fefor fezero febefore feperforming fethe fedivision. f e Ignore fethe feerror feand felet fethe feprogram fecrash. fe Implement fea fetry-except feblock feto fecatch fethe feZeroDivisionError feand felog fean feappropriate femessage.
  3. What feis fethe ferecommended fesecure fehashing fealgorithm fefor fepassword festorage? f e SHA- 1 f e SHA- 256 f e MD f e bcrypt
  4. What feis fethe fe primary fefunction f e used feto feencrypt feplain fe text fein feAES feCTR femode? f e DES feencryption fefunction f e AES feencryption f e function

f e Blowfish feencryption fefunction f e RSA feencryption fefunction

  1. Describe fewhy feusing fethe fe% feoperator fefor festring feformatting fecan felead feto fesecurity fevulnerabilities fein fePython. f e f e The f e % feoperator feis fethe fefastest femethod fefor festring feformatting. f e Using fethe fe% feoperator feis ferecommended fefor feall festring feoperations. f e f e The fe % f e operator feis fethe feonly feway feto feformat festrings fein fe Python. f e Using fethe fe% feoperator fecan feexpose fesensitive feinformation feif fethe festring feis f e not fe properly fesanitized, feallowing f e for fepotential feinjection f e attacks.
  2. What feis fethe feprimary femethod feused feto feensure fethat feonly fethe feowner feof fean feobject fecan feaccess feitsfedatafein fePython? f e Encrypt fethe fedata fewith feAES f e Apply fepassword fehashing f e f e Implement f e object-level f e authorization f e Use fepublic feaccess femodifiers
  3. Describe fehow feyou fewould feimplement fea ferange fevalidation fecheck fefor fea fenumeric feinput fein fePython. f e You fecan feuse fea feloop feto fecontinuously feprompt fefor feinput feuntil fea fevalid fenumber feis feentered. f e You fecan feuse fea fetry-except feblock feto fecatch feerrors fewhen fethe feinput feis fenot fea fenumber. f e You fecan feuse fean feif festatement feto fecheck feif fethe feinput feis fegreater fethan feor feequal feto fe 1 feand feless fethan feor feequal feto fe10.