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.

Slettennnnn 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')

INSTR functions

The INSTR functions (INSTR, INSTRB, INSTRC, INSTR2, and INSTR4) searches a string for a substring using characters and returns the position in the string that is the first character of a specified occurrence of the substring.

INSTR4} (string , substring [, position [, occurrence]]) Arguments The text expression to search.

The default value of position is 1, which means that the function begins searching at the beginning of string.

String Functions

Returns a substring from a string, using a delimiter character to divide the string into a sequence of tokens.

Note: The split and custom split commands are available for the following data sources types: Tableau data extracts, Microsoft Excel, Text File, PDF File, Salesforce, OData, Microsoft Azure Market Place, Google Analytics, Vertica, Oracle, MySQL, PostgreSQL, Teradata, Amazon Redshift, Aster Data, Google Big Query, Cloudera Hadoop Hive, Hortonworks Hive, and Microsoft SQL Server.

The following table shows which data sources support negative token numbers (splitting from the right) and whether there is a limit on the number of splits allow per data source.

A SPLIT function that specifies a negative token number and would be legal with other data sources will return this error with these data sources: “Splitting from right is not support by the data source.”  

C Program to find substring in a string

Learn how to find a substring in a given string in C language Like, Comments, Share and SUBSCRIBE visit for all FREE videos

Strings in C (HINDI/URDU)

Subscribe : Website : FB :

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.

Find Special Character in a string using Sql

In this video we learn how to find the special character , number in a string using sql server. -- How to Find Number and character in a string SELECT ...

BluePrism - String Reg Expressions || Reality & Useful

Hi Friends, Now we will discuss about 'Utility - String' Regular expressions -------------------------------------------------------------------------- Why we need to use regular ...

Important Character String functions in R Studio

Hello Friends, This video is very helpful if you want to learn some basic commands to manipulate string variables. It helps in learning how to concatenate two ...

Program to calculate length of the string in C Hindi

Like, Comments, Share and SUBSCRIBE.

Program to Count Uppercase and Lowercase Letters in a String in C (HINDI)

Counting Uppercase and Lowercase Letters in a String in C (HINDI) Count Uppercase and Lowercase Letters in a String in C (HINDI) Subscribe ...

String Functions like LEN - Substring in SQLServer

In this video tutorial on SQL Server 2008, we cover sql string functions that are commonly used. Here are the SQL ..

Python Find String Method

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