O'Reilly logo

Introduction to Python® Programming and Developing GUI Applications with PyQT by B. M. Harwani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Sequences

This chapter covers the following:

  • How data is stored in a string

  • Creating and displaying one- and two-dimensional arrays

  • List slicing and its methods

  • Creating tuples and searching for elements

  • Key/value pairs and their methods

  • Union, intersection, and difference operators

Sequences

A sequence contains objects that are kept in a specific order. You can identify an object in a sequence by its index location. Also, you can extract from a sequence with the slicing operation. In this chapter you will look at three examples of sequences: lists, tuples, and strings.

  • Strings use quotes, such as 'Hello', "Hello", '"Hello"', """Hello""".

  • Lists use square brackets, such as [Tiger, Coffee, 1,'a', 10.50, 'b'].

  • Tuples use parentheses, such as (Tiger, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required