Docsity

WGU D385 Coding Lab 2026/2027 | Quick Fixes & 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 & 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 olhow olthe olleast olprivilege olprinciple olcan olenhance olsecurity olin ola olsystem. o l By ollimiting oluser olpermissions, olthe olleast olprivilege olprinciple olreduces olthe olrisk olof olunauthorized olaccess oland olpotential oldamage. o l o l By o l providing o l unrestricted o l access, o l it o l enhances o l system o l performance. o l o l By olgranting o l users o l full olaccess, o l it o l encourages o l collaboration. o l o l By olallowing o l users olto olaccess olall olfiles, o l it ol simplifies o l user olmanagement.
  2. Describe olthe olconsequences olof olfailing olto olvalidate olserialized oldata olbefore oldeserialization. o l o l Failing o l to olvalidate o l serialized o l data o l has o l no o l significant o l impact. o l o l Failing o l to olvalidate o l serialized o l data o l improves o l system o l efficiency. o l Failing olto olvalidate olserialized oldata olonly olaffects olperformance. ol Failing olto olvalidate olserialized oldata olcan ollead olto olsecurity olvulnerabilities oland oldata olcorruption.
  3. Why olis olbcrypt olpreferred olover olMD5 olfor olpassword olhashing? o l MD5 olis olfaster oland olrequires olless olcomputational olpower. o l MD5 olis olmore olwidely olused olin olmodern olapplications. o l Bcrypt olis oldesigned olto olbe olslow oland olincludes ola olsalt, olmaking olit olmore olsecure olagainst olbrute-force olattacks. o l Bcrypt olis oleasier olto olimplement olthan olMD5.
  4. A olCustom olObject olis olused olto olgather olfeedback olabout olEmployees. olThis olObject olshould olbe olPrivate olso olEmployees olcannot olsee oleach olother's olRecords. olOnly olthe olCEOolshould olsee olallolRecords. olHow olcan olthis olbeoldone?

o l Encrypt olthe o l plain o l text olwithout olany olformatting.

  1. Describe olthe olconcept olof olobject-level olauthorization oland olits olimportance olin olsecuring oldata olaccess. o l Object-level olauthorization olallows olany oluser olto olaccess oldata, olpromoting oltransparency. o l o l Object-level olauthorization o l is o l irrelevant o l in o l modern o l programming. o l Object-level olauthorization olrestricts oldata olaccess olto olthe olowner, olensuring olthat olsensitive olinformation olis olprotected. o l Object-level olauthorization olis olonly olnecessary olfor olpublic oldata.
  2. What olmethod olshould olbe olused olto olsafely olformat olstrings olin olPython olto olavoid olexposing olsensitive olinformation? o l Concatenate olstrings olusing olthe ol+ oloperator. o l Directly olprint olthe olsecret olkey olwithout olformatting. o l o l Use olf-strings olor olthe olformat() o l method o l instead o l of o l the o l % o l operator. o l Use olthe ol% oloperator olfor olstring olformatting.
  3. Which olof olthe olfollowing olpolicies olshould olbe olused olwhen olassigning olpermissions, olgiving olusers olonly olthe olpermissions olthey olneed olto oldo oltheir olwork oland olno olmore? o l Separation olof olduties o l Physical olaccess olcontrol o l Acceptable oluse o l Least olprivilege
  4. Format ol string olvulnerabilities olarise o l primarily olbecause:

o l Assumptions olare olmade olon olthe olsize olof olthe oloutput olbuffer

  1. What olis olthe olleast olprivilege olprinciple olin olthe olcontext olof olfile olpermissions? o l Allowing olusers olto olmodify olfile olpermissions olfreely. o l Granting olall olpermissions olto olall olusers. o l Assigning olonly olthe olpermissions olnecessary olfor olusers olto olperform oltheir oltasks. o l Restricting olaccess olto olfiles olbased olon oluser olroles.
  2. If olyou olencounter ola oldivision olby olzero olerror olin ola olPython olapplication, olhow olwould olyouolmodifyoltheolcodeoltoolhandleolthisolsituationolgracefully? o l Change olthe oldivision oloperation olto olmultiplication olto olavoid olthe olerror. o l Use ola olconditional olstatement olto olcheck olfor olzero olbefore olperforming olthe oldivision. o l Ignore olthe olerror oland ollet olthe olprogram olcrash. ol Implement ola oltry-except olblock olto olcatch olthe olZeroDivisionError oland ollog olan olappropriate olmessage.
  3. What olis olthe olrecommended olsecure olhashing olalgorithm olfor olpassword olstorage? o l SHA- 1 o l SHA- 256 o l MD o l bcrypt
  4. What olis olthe ol primary olfunction o l used olto olencrypt olplain ol text olin olAES olCTR olmode? o l DES olencryption olfunction o l AES olencryption o l function

o l Blowfish olencryption olfunction o l RSA olencryption olfunction

  1. Describe olwhy olusing olthe ol% oloperator olfor olstring olformatting olcan ollead olto olsecurity olvulnerabilities olin olPython. o l o l The o l % oloperator olis olthe olfastest olmethod olfor olstring olformatting. o l Using olthe ol% oloperator olis olrecommended olfor olall olstring oloperations. o l o l The ol % ol operator olis olthe olonly olway olto olformat olstrings olin ol Python. o l Using olthe ol% oloperator olcan olexpose olsensitive olinformation olif olthe olstring olis o l not o l properly olsanitized, olallowing o l for olpotential olinjection ol attacks.
  2. What olis olthe olprimary olmethod olused olto olensure olthat olonly olthe olowner olof olan olobject olcan olaccess olitsoldataolin olPython? o l Encrypt olthe oldata olwith olAES o l Apply olpassword olhashing o l o l Implement o l object-level o l authorization o l Use olpublic olaccess olmodifiers
  3. Describe olhow olyou olwould olimplement ola olrange olvalidation olcheck olfor ola olnumeric olinput olin olPython. o l You olcan oluse ola olloop olto olcontinuously olprompt olfor olinput oluntil ola olvalid olnumber olis olentered. o l You olcan oluse ola oltry-except olblock olto olcatch olerrors olwhen olthe olinput olis olnot ola olnumber. o l You olcan oluse olan olif olstatement olto olcheck olif olthe olinput olis olgreater olthan olor olequal olto ol 1 oland olless olthan olor olequal olto ol10.