Think Python: How to Think Like a Computer Scientist
Variable-Length Argument Tuples Functions can take a variable number of arguments. A parameter name that ...
Lists and Tuples zip is a built-in function that takes two or more sequences and returns a list of ...
If you combine zip, for and tuple assignment, you get a useful idiom for traversing two (or more) sequences at ...
Dictionaries and Tuples Dictionaries have a method called items that returns a sequence of tuples, where ...
each tuple to last and first, then prints the name and corresponding telephone number. There are two ways ...
Sequences of Sequences I have focused on lists of tuples, but almost all of the examples in this chapter a ...
Debugging Lists, dictionaries and tuples are examples of data structures; in this chapter we are starting to ...
Glossary tuple: An immutable sequence of elements. tuple assignment: An assignment with a sequence on the ri ...
Exercises Exercise 12-1. Write a function called most_frequent that takes a string and prints the letters ...
What is the longest English word, that remains a valid English word, as you remove its letters one at a time ...
...
Chapter 13. Case Study: Data Structure Selection At this point you have learned about Python’s core da ...
Word Frequency Analysis As usual, you should at least attempt the exercises before you read my solutions. Exercis ...
Random Numbers Given the same inputs, most computer programs generate the same outputs every time, so ...
hist {'a': 2, 'b': 1} your function should return 'a' with probability 2/3 and 'b' with probability 1/ ...
Word Histogram You should attempt the previous exercises before you go on. You can download my solution from ht ...
print('Number of different words:', different_words(hist)) And the results: Total number of words: 161080 Number o ...
Most Common Words To find the most common words, we can make a list of tuples, where each tuple conta ...
Optional Parameters We have seen built-in functions and methods that take optional arguments. It is poss ...
Dictionary Subtraction Finding the words from the book that are not in the word list from words.txt is ...
«
7
8
9
10
11
12
13
14
15
16
»
Free download pdf