-
Book Overview & Buying
-
Table Of Contents
Machine Learning For Dummies
By :
Of all the data types, strings are the most easily understood by humans and not understood at all by computers. A string is simply any grouping of characters that you place within double quotation marks. For example, myString = “Python is a great language.” assigns a string of characters to myString.
The computer doesn’t see letters at all. Every letter you use is represented by a number in memory. For example, the letter A is actually the number 65. To see this for yourself, type ord(“A”) at the Python prompt and press Enter. You see 65 as output. You can convert any single letter to its numeric equivalent using the ord() command.
Because the computer doesn’t really understand strings, but strings are so useful in writing applications, you sometimes need to convert a string to a number. You can use the int() and float() commands to perform this conversion. For example, if you type myInt = int(“123”) and...
Change the font size
Change margin width
Change background colour