Posts in 2021

  • 10-13 Stringy

    Wednesday, October 13, 2021 in Daily

    Stringy Storage of a Graph The (until now fictional) “string method” of storing a graph lists strings of connected vertices on every line. Assignment: Write a function that accepts an already open file (returned from open) and creates an …

    Read more

  • 10-13 Basics

    Wednesday, October 13, 2021 in Daily

    Python proficiency questions. Suppose x is an object of class CC. What method is run by str(x)? Give an efficient way to remove the trailing newlines from an array of strings read from a file. ['the\n','mouse\n','went\n','up\n','the\n','clock\n'] …

    Read more

  • 10-08 Shortest

    Thursday, October 07, 2021 in Daily

    Skills base Sorting into a new container: ys = sorted(..., reverse=True) Sorting by mutation, changing the existing container: xs.sort(reverse=True) Field width: f"{x:10}" puts x in a space 10 characters wide. Improvements to graph.py …

    Read more

  • 10-06 Graph

    Wednesday, October 06, 2021 in Daily

    Default Dictionary Sometimes you want to have a “default value” in a dictionary. The default value is returned whenever you ask for the value of a key that is not in the dictionary. A typical use would be counting words, where the count …

    Read more

  • 09-30

    Friday, October 01, 2021 in Daily

    Examples are important. Work at an appropriate level. Debugging is important. Observations In my opinion, problem solving in computer science comes through working examples. Slow down enough to make examples and think through your program to make …

    Read more

  • 09-29

    Wednesday, September 29, 2021 in Daily

    Opener: Bucket Brigade bucket brigade You absolutely have the skills to do this problem. Do some examples and find out how it works! Portfolio Using good Pythonic code, solve all three problems in some level of the 2019 US Open. Contents of a …

    Read more

  • 09-28

    Tuesday, September 28, 2021 in Daily

    Reading: classes in Python. An introduction to object-oriented programming in Python. Section 9.2 is esoteric, you should skip it on the first reading. Section 9.3 is important. Translate into Python: Candy class Translate into Python: Animals: …

    Read more

  • 09-23

    Thursday, September 23, 2021 in Daily

    Upcoming Next week: Object oriented programming in Python. Tomorrow: Quiz on Python. Soon: searching and backtracking Week 6: graph theory. Skill of the day Python’s f-strings give a quick and easy way to create a string. Example: predator = …

    Read more

  • 09-21

    Friday, September 17, 2021 in Daily

    Reading You need to convert strings to numbers with the int function. Read a single number: int(input()) Read a list of numbers: [int(n) for n in input().split()] If different items in the list have different meanings, it can be useful to give them …

    Read more

  • 09-17

    Friday, September 17, 2021 in Daily

    (overlap) Given two lists of numbers, produce a sorted list of elements common to both of them. overlap [10, 20, 17, 30, 15, 18] [18, 30, 5, 17, 21, 90] == [17, 18, 30] Turn the following table into a dictionary called q2: Combo Effectiveness …

    Read more