CS105: Unit 3 corrections, notes and suggestions

CS105: Introduction to Python
Unit 3: Input and Flow Control Statements


3.2: Using Conditional Statements
if, else, and elif statements

  1. if-else branches (general)
    Reference Page id=29218
  • The code segments on this page do not have proper indentation. Consider using &nbsp; within tags inside of the <pre> block to rectify. Other pages with indented code are doing this correctly.

3.2: Using Conditional Statements
if, else, and elif statements
2. if-else statement
Reference Page id=29218&chapterid=4709

  • The first and second code segments are duplicated and there is no commentary to annotate what should be learned here.

  • Reviewing this code, it appears as though a user input value >= 70 will indicate the appropriate grade, as well as an erroneous messsage indicating that it is an F grade. This is because the else statement on the last line of the first two code blocks will execute for grade >= 70 and < 60.

  • Presumably, the focus is on use of the series elif statements, and that once a condition is met, its block runs and exits the if statement.


3.2: Using Conditional Statements
if, else, and elif statements
4. Nested if-else statements
Reference Page id=29218&chapterid=4711

  • In all three code segments, the last two lines are an else block that should be outdented to match the outer if grade >= 90.

3.2: Using Conditional Statements
if, else, and elif statements
8. Membership and identity operators
Reference Page id=29218&chapterid=4715

  • It may be useful to the learner if a brief description of what a list and a dictionary is provided, and how they differ. A list is a series of zero or more values encased within an open and closing brackets [] with each value delineated by a comma. A dictionary is an unordered collection that is a structure comprised of zero or more key-value pairs encased with an open and closing brace {} with each key-value pair delineated by a comma, and the key and values delineated by a colon. Both myContainer and otherContainer are examples of lists, while MyNamesContainer is an example of a dictionary.

  • In the last example, there are spelling errors in two print statements for both the name of the variable myContainer and otherContainer as myContainter and otherContainter respectively.


3.2: Using Conditional Statements
if, else, and elif statements
9. Code blocks and indentation
Reference Page id=29218&chapterid=4719

  • The commentary on the page says to be consistent, either use 4 spaces or a tab (3 spaces). However, examples on this page are all indented by 6 spaces

3.3 Loop and Iterations
Using “while” loops
Reference Page id=29387

  • In the section Let’s start with while loops, there is a series of images without commentary. Recommend placing these in a table with another column for description, or provide a caption, or make use of alt or title text to describe what is happening. The impression I get is that the first 7 images represent issuing a command (statement) multiple times, while next 13 images show what would happen if a command was being iterating for as long as a condition was being met.

3.3 Loop and Interations
Using “for” loops
Reference Page id=29223


Unit 3 Assessment

  • Question 3 has a formatting error in the code segment. Line 4 should be indented. Without this indentation, an error would be expected.

  • Question 4 has formatting errors in the code segment. Line 4 and 6 should be indented. Without this indentation, an error would be expected.

  • Question 5 may have a formatting error in the code segment. It’s unclear if the last line should be indented or not.

  • Question 15 has incorrect guidance on the output message for #2. This should actually be You did not enter a value greater than 5 and less than or equal to 10

1 Like