CS110A Week 12 Day 2 lesson on Thursday 11/05/2026
Overview
Indika Walimuni teaches Python dictionaries, Boolean logic, conditional statements, and comparisons through worked class examples, including calculating letter grades and storing each student’s score and grade in a dictionary. The lesson also reviews module assignments, shares personal-statement writing advice, and previews upcoming loop and random-shape programming work.
Key takeaways
- A dictionary assignment such as info['name'] = input(...) creates the key if it does not already exist, while dictionary keys themselves must be immutable.
- A reusable grading function should accept a numeric average and return a letter grade; the main program should handle retrieving that score from a student dictionary.
- A dictionary can map student names to lists containing both a score and a calculated grade, and dictionary lookup avoids scanning entries one by one.
- Python and returns True only when both operands are true, or returns True when at least one operand is true, and not reverses the result.
- String comparisons use character-by-character Unicode ordering, and floating-point equality may be unreliable because calculations can contain representation error.
- Randomly mapping integers to rock-paper-scissors moves or drawing shapes uses the same programming pattern: define outcome ranges, then select an action with conditional logic.
Chapters
- Initialize an empty Python dictionary named info, then assign input values to the name and age keys.
- Assigning to a missing key with square brackets creates that dictionary key automatically.
- Print the dictionary to verify that the entered name and age are stored as key-value pairs.
- Separate variables for name and age are sufficient for a simple task; a dictionary is used here to practice key-value access.
- Dictionary keys must be immutable, so strings can serve as keys but lists cannot.
- Lists are suitable dictionary values when their contents may change, while tuples suit values intended to remain fixed.
- The grading exercise receives a student’s average class total from a dictionary and must return a letter grade.
- The assignment prohibits manually entering the answer or using a for loop.
- Jack’s example score is used to identify an A under the stated grading criteria.
- The demonstrated thresholds assign A for scores of at least 89, B for 79 through 89, C for 69 through 79, and D for 59 through 69.
- An else branch returns F for scores below the D range, so no additional threshold test is needed.
- Indika Walimuni contrasts independent if statements with an if-elif-else chain and recommends direct returns when a matching grade is found.
- The function calculate_letter_grade accepts an average class total rather than an entire student dictionary.
- Keeping dictionary access in the main program makes the grading function reusable with a plain numeric score.
- The function returns a letter grade according to the class grading criteria.
- The class-totals dictionary maps student names such as Kate to numeric scores such as 90.
- A separate grades dictionary stores a list for each student, with the score and calculated letter grade as list items.
- Use dictionary square-bracket access to retrieve a student’s score, then append the score and calculate_letter_grade result to the corresponding list.
- Python dictionaries can contain other dictionaries as values, creating nested key-value structures.
- Indika Walimuni connects nested dictionaries to JSON-style data and key-value storage.
- Dictionary lookup is described as average constant-time access, unlike searching a list item by item.
- The age-categories task asks for a function that reports whether one, both, or neither of two people are between 18 and 64 inclusive, using logical operators.
- The highway-number describer uses if-else rules based on number ranges and odd or even values to produce a route description.
- The rock-paper-scissors assignment uses a random number to select the computer’s move and determine the outcome.
- The featured Stanford professor recommends an authentic personal statement that reveals personality rather than presenting a flat list of accomplishments.
- Use specific stories to show commitment, connect experiences to the target program, and avoid clichés or unfamiliar words used incorrectly.
- Address application weaknesses directly, explain growth, and open with a compelling scene rather than inventing or embellishing details.
- The truth table for and produces True only when both Boolean operands are True.
- The truth table for or produces True when at least one operand is True, while not reverses a Boolean value.
- Python logical operators combine comparison results, and their precedence is lower than comparison operators.
- Python Boolean literals are True and False, with capitalized initial letters.
- For an age of 19, the expression age > 16 and age < 25 evaluates True because both comparisons are true.
- Parentheses are evaluated before not, allowing a compound Boolean expression to be inverted.
- A tax-bracket condition for income outside a range can be written by reversing the boundary comparisons and joining them with or.
- The complement of an inside-range condition can also use not, but equality boundaries must be handled correctly.
- Testing boundary cases revealed that the comparison operators must preserve the intended inclusive or exclusive endpoints.
- The cucumber exercise prints an unacceptable-amount message when the count is less than or equal to 10 or greater than 20.
- Independent if statements all run in sequence, so their order matters when implementing grade checks without an elif chain.
- For grade checks using separate if statements, testing A before B, C, and D prevents an earlier return from producing the wrong result.
- A time-after-class example uses multiple independent if statements to print outputs for separate conditions.
- An if-else placed inside another conditional is a nested if-else structure.
- Python Tutor is recommended for tracing how the separate conditions execute.
- Floating-point calculations can contain tiny representation errors, so exact equality checks may fail when values are intended to match.
- String comparisons proceed character by character using Unicode code-point values, rather than comparing the whole strings by length.
- The ord function returns a character’s numeric code point; lowercase j has a higher value than uppercase J, affecting comparisons such as Jill and Bill.
- The class briefly revisits code blocks and indentation as core Python structure.
- Indika Walimuni says the class is nearly done with the current chapter on conditional logic.
- The next week’s planned topic is loops, presented as a key way computers repeat operations efficiently.
- The random-shapes discussion asks students to draw circles, equilateral triangles, and squares using randomly selected choices.
- Students must define which random-number outcomes correspond to each shape and implement the decision with conditions.
- The same mapping strategy applies to the rock-paper-scissors program, where random values select rock, paper, or scissors.
Transcript excerpt
0:00 Good morning guys. So this is our agenda today. Um [clears throat] okay so um [clears throat] so let me show you. So um S asked a question um on the dictionaries how to use that one right? So let me show you that. Um so let me first open the problem. Um, okay. I think this one
1:00 this one, right? Okay. So, basically it says given the names and ages of two people, write a Python program to return if one uh both or neither people are between 18 64 uh inclusive. you must use logical and o and uh must return the word. So basically um what I'm going to show you is like you know how you can utilize a dictionary to get the the input. Okay. So, uh if you want to you can do that, right? So, uh so like right here. So, I actually asked okay. So, you you do it this way. But how do we write this into a dictionary? Right? That that was the
1:48 question, right? So, uh so let me uh show it to you over here in the uh in here. Okay. So, so let's say uh you [clears throat] have um info dictionary, right? So, info. Okay. So, first you have to initialize. Okay. All right. All right. So, you have to initialize your dictionary. Okay. S this is your um question I'm doing. Okay. So, uh and then well, you need to add a key, right? So, so I mean we remember we didn't actually um learn dictionaries in depth with just touch based right but uh since
2:39 you asked it's not that difficult to actually learn so if you want to add a key right so basically what you do is okay so and then you want to input let's
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, indika walimuni.