Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Python 3 and Data Visualization

You're reading from   Python 3 and Data Visualization Mastering Graphics and Data Manipulation with Python

Arrow left icon
Product type Paperback
Published in Aug 2024
Publisher Mercury_Learning
ISBN-13 9781836645719
Length 281 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Mercury Learning and Information Mercury Learning and Information
Author Profile Icon Mercury Learning and Information
Mercury Learning and Information
Oswald Campesato Oswald Campesato
Author Profile Icon Oswald Campesato
Oswald Campesato
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface
1. Chapter 1: Introduction to Python 3 2. Chapter 2: NumPy and Data Visualization FREE CHAPTER 3. Chapter 3: Pandas and Data Visualization 4. Chapter 4: Pandas and SQL 5. Chapter 5: Matplotlib for Data Visualization 6. Chapter 6: Seaborn for Data Visualization 7. Index
Appendix: SVG and D3

PYTHON while LOOPS

You can define a while loop to iterate through a set of numbers, as shown in the following examples:

>>> x = 0
>>> while x < 5:
...   print(x)
...   x = x + 1
... 
0
1
2
3
4
5

Python uses indentation instead of curly braces that are used in other languages such as JavaScript and Java. Although the Python list data structure is not discussed until later in this chapter, you can probably understand the following simple code block that contains a variant of the preceding while loop that you can use when working with lists:

lst  = [1,2,3,4]

while lst:
  print('list:',lst)
  print('item:',lst.pop())

The preceding while loop terminates when the lst variable is empty, and there is no need to explicitly test for an empty list. The output from the preceding code is here:

list: [1, 2, 3, 4]
item: 4
list: [1, 2, 3]
item: 3
list: [1, 2]
item: 2
list: [1]
item: 1

This concludes the examples that use the split() function in order to process words and characters in a text string. The next part of this chapter shows you examples of using conditional logic in Python code.

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Python 3 and Data Visualization
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon