Learning Objectives:
Software Tools Needed: Web browser to access textbook and an IDE (on-line or on computer) with core Python 3.6+ loaded.
Lab Notes: Download the outline and focus questions to guide you while working through this lab. These are a useful tool for note taking and as well as studying for the quizzes and final exam.
Last week, we introduced file I/O. Working with files follows a similar format in most programming languages:
If you didn't finish last week, work through the chapter on File I/0 from the CSCI 127 textbook:
For today's lab, take your sketches of algorithms from last week and turn them into Python programs:
In Lecture, we highlighted Chapter 2 (algorithm analysis) of the textbook. For this lab, we're focusing on first sections of the chapter:
Work through the interactive examples in Sections 2.1 & 2.2: Benchmarking Programs. As you work through, make sure to note how you can measure the time a program takes to execute (the chapter has highlights two different approaches: time
library in this section and timeit
library later in the chapter in Section 2.5).
Sections 2.3 introduces Big O Notation. We sketched the main ideas in lecture. Reread the section now and then test your understanding by completing Problems 1-5 of the Chapter 2 Exercises.
For Classwork 3, we sketched algorithms for anagram detection. Sections 2.4 gives several different solutions and analyses the running time. Work through the chapter, and then try Program 9.
For additional practice on core Python, see the HackerRank prepare series:
HackerRank: Prepare Python
Click the Easy
option on the right hand menu, and work through their Python challenges.
For more practice on using dictionaries to solve problems, here are some popular ones on anagrams and using dictionaries as an efficient approach: