Summary

In this chapter, we saw the use of the assignment using operator =, numeric addition using + (with type-promotion of an int to a float), and augmented assignment with +=. We also saw the print operator and learned that since IDLE automatically prints expressions, we use print much less often when using IDLE. We also saw that comments are introduced by a # and continue until the end of the line. In fact Python can separate statements with semicolons but it is very unusual to do this: In Python, a statement occupies a single line; newline is the statement separator.

We have learned how Python strings are created by using quotes, and how strings can be sliced and concatenated using the [] and + operators. We also summarized some of the key methods that Python strings provide: We will see numerous examples of their use in working code throughout the book. We saw that QString is a distinct Unicode string type and that we need to have a policy governing our use of QStrings and Python strings (normally unicode strings) when programming using PyQt.

The chapter introduced Python's major collection types. Tuples provide a nice way of grouping items together and can be used as dictionary keys. Lists are ordered and can hold duplicates. They provide fast insertions and deletions, and fast index-based lookup. Dictionaries are unordered and have unique keys. Like lists, they provide fast insertions and deletions. They also provide fast key-based lookup. Sets can be thought of as dictionaries that don't hold values. We will make great use of all these types in the rest of the book.

★The value 0.00000000000000012246063538223773is close to 0 as expected.

Finally, we had a quick glimpse at some of Python's built-in functionality and at one of its mathematics modules. In Chapter 3, we will see how to create our own modules. But before that, we need to learn about Python's control structures so that we can branch, loop, call our own functions, and handle exceptions—all of which are the subject of the next chapter.

Was this article helpful?

0 0
Tube Me Some Traffic

Tube Me Some Traffic

Video Marketing Will Never Be The Same Again. Here's How YOU - Or ANYONE - Can Leverage On The Internet's 4th MOST TRAFFICKED WEBSITE TO BOOST YOUR POPULARITY amp PUBLICITY FOR BUSINESS via Video Marketing! With The Emergence Of Web Video Popularity, You CANNOT Afford To Miss Out On This Exponentially Growing Trend - Because It Could Make Or Break Your Popularity amp Business Growth!

Get My Free Ebook


Post a comment