AI News, Difference between revisions of "How to Think Like a Computer Scientist: Learning with Python 2nd Edition/Solutions"

Difference between revisions of "How to Think Like a Computer Scientist: Learning with Python 2nd Edition/Solutions"

The following section contains answers to the exercises in the Book.

Why does a call to num_digits(-24) result in an infinite loop (hint: -1/10 evaluates to -1)?

The loop will end when n = 0, and per above -1/10 == -1, causing an infinite loop.

Encapsulate: in a function named count_letters, and generalize it so that it accepts the string and the letter as arguments.

Now rewrite the count_letters function so that instead of traversing the string, it repeatedly calls find (the version from Optional parameters), with the optional third parameter to locate new occurences of the letter being counted.

ceil function finds the lowest integeral value greater than or equal to x.

deepcopy would have come handy in exercises you didn't have to solve regarding object reference, thus no answer is excpected here.

The word 'alice' occurs 386 times (not including 12 occurences of 'alice's')

Python Find String Method

Be sure to like, share and comment to show your support for our tutorials. ======================================= Channel - ..

Extract Text from cells in Excel - How to get any word from a cell in Excel

More help: Excel Forum: This tutorial shows you how to input a formula into a .

Excel Magic Trick 323: Partial Text VLOOKUP (Fuzzy Match)

Two formulas: VLOOKUP function with wild card criteria for the lookup_value and LOOKUP / SEARCH functions formula with 2^15 number. See what happens ...

Python Count String Method

Be sure to like, share and comment to show your support for our tutorials. ======================================= Channel - ..

Excel Magic Trick 559: Extract Nth Word In Text String

See how to Extract First, Last or Nth Word In Text String using the following functions: SUBSTITUTE, LEN, SEARCH, REPLACE, LEFT, RIGHT, MID.

Microsoft Access Tutorial: String Functions (Left, Right, InStr, Trim)

In this Microsoft Access tutorial, I'll show you how to break up text fields into smaller parts using Left, Right, Trim, and InStr.

How to Return an Array from a Function in C Part 1/2

Master converting between hex, binary and decimal in your head with this game: ..

Extract Text Between Two Characters in Excel

Like this tip? Find more at ☆ Extract text between two characters in a cell. This video looks at how to extract text between two forward ..

Contains and IndexOf String Functions - VB .Net

In this tutorial I will explain and demonstrate the IndexOf and Contains functions. Contains is a boolean function and it simply returns true or false based on ...

How to Check if a String only Contains Alphanumeric Characters in Python

In this lesson we're going to talk about that how to check if a string only contains alphanumeric characters by using isalnum() method in Python programming ...