Coee Break Python
Slicing
24 Workouts to Master Slicing in
Python, Once and For All
Christian Mayer
November 2018
A puzzle a day to learn, code, and play.
ii
Contents
Contents iii
1 Introduction 1
2 How to Use This Book 4
2.1 What Is a Code Puzzle? . . . . . . . . . . 4
2.2 Why Puzzle-based Learning? . . . . . . . . 5
2.3 How to Measure Your Python Skills with
This Book? . . . . . . . . . . . . . . . . . 8
3 A Quick Overview of the Python Language 13
3.1 Keywords . . . . . . . . . . . . . . . . . . 14
3.2 Basic Data Types . . . . . . . . . . . . . . 17
3.3 Complex Data Types . . . . . . . . . . . . 20
3.4 Classes . . . . . . . . . . . . . . . . . . . . 25
3.5 Functions and Tricks . . . . . . . . . . . . 28
iii
www.dbooks.org
iv
CONTENTS
4 Introduction Slicing 32
4.1 Intermezzo: Indexing Basics . . . . . . . . 32
4.2 Slicing . . . . . . . . . . . . . . . . . . . . 33
4.3 The Step Size in Slicing . . . . . . . . . . 35
4.4 Overshooting Indices in Slicing . . . . . . 37
4.5 Summary Basic Python Slicing . . . . . . 38
4.6 Frequently Asked Questions . . . . . . . . 40
5 Code Puzzles Slicing 61
6 Final Remarks 74
1
Introduction
The main driver for mastery is neither a character trait
nor talent. Mastery comes from intense, structured train-
ing. The author Malcolm Gladwell formulated the fa-
mous rule of 10,000 hours based on research from psy-
chology and neurological science.
1
The rule states that
if you have average talent, you will reach mastery in
any discipline by investing approximately 10,000 hours
of intense training. Bill Gates, the founder of Microsoft,
reached mastery at a young age as a result of coding for
more than 10,000 hours. He was committed and passion-
ate about coding and worked long nights to develop his
skills.
If you are reading this book, you are an aspiring coder
and you seek ways to advance your coding skills. You
1
Malcolm Gladwell
Outliers: The Story of Success
.
1
www.dbooks.org