Skip to content

Instantly share code, notes, and snippets.

View Crytographer1Cypher's full-sized avatar

Crytographer1Cypher

View GitHub Profile
@misterhtmlcss
misterhtmlcss / discussion-unit4.py
Last active December 9, 2021 02:55
Define precondition and postcondition show return errors
# CS1101 - Discussion Forum Unit 4
# Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working.
# ✓ Define "precondition" and "postcondition" as part of your description. (First two paragraphs)
# ✓ Describe each possibility in your own words. (All three paragraphs)
# A precondtion is a problem before the function’s arguments are passed into the parameters (Downey, A. 2015). Are there arguments being passed? Sometimes a function is called a long ways away from where it’s defined. With languages like Python it’s often critical to name parameters effectively so that the correct arguments are passed. This can be as simple as missing a type e.g. ‘5’ instead of 5.
# A postcondition is a problem that follows from the point immediately following the arguments being passed (Downey, A. 2015). A really simple example could be `function (a, b) { b -a }`. No matter the language we can all see how it’s unlikely that a human mind would order the parameters as a follow
@misterhtmlcss
misterhtmlcss / discussion-unit-3.py
Last active March 17, 2024 04:58
Describe the differences between chained and nested conditionals
"""
Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook.
Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional. Do not copy the example from the textbook.
✓ Describe the difference between a chained conditional and a nested conditional.
✓ Give your own example of each.
✓ Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional.
✓ Describe a strategy for avoiding nested conditionals (bottom).
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>