Python One Liners 1st Edition Christian Mayer pdf download
Python One Liners 1st Edition Christian Mayer pdf download
pdf download
https://ebookfinal.com/download/python-one-liners-1st-edition-
christian-mayer/
https://ebookfinal.com/download/python-one-liners-1st-edition-
christian-mayer/
https://ebookfinal.com/download/reforming-reformation-thomas-f-mayer/
https://ebookfinal.com/download/jerusalem-idea-and-reality-1st-
edition-tamar-mayer/
Casing and Liners for Drilling and Completion 1st Edition
Ted G. Byrom (Auth.)
https://ebookfinal.com/download/casing-and-liners-for-drilling-and-
completion-1st-edition-ted-g-byrom-auth/
https://ebookfinal.com/download/outpost-of-hellenism-stanley-mayer-
burstein/
https://ebookfinal.com/download/encyclopedia-of-film-noir-geoff-mayer/
https://ebookfinal.com/download/python-tricks-a-buffet-of-awesome-
python-features-1st-edition-dan-bader/
https://ebookfinal.com/download/the-social-media-business-
equation-1st-edition-eve-mayer-orsburn/
Python One Liners 1st Edition Christian Mayer Digital
Instant Download
Author(s): Christian Mayer
ISBN(s): 9781718500518, 1718500513
Edition: 1
File Details: PDF, 6.36 MB
Year: 2020
Language: english
PYTHON ONE-LINERS
Write Concise, Eloquent Python Like a
Professional
by Christian Mayer
San Francisco
PYTHON ONE-LINERS. Copyright © 2020 by Christian Mayer.
All rights reserved. No part of this work may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying,
recording, or by any information storage or retrieval system, without the prior
written permission of the copyright owner and the publisher.
ISBN-10: 1-7185-0050-5
ISBN-13: 978-1-7185-0050-1
No Starch Press and the No Starch Press logo are registered trademarks of No
Starch Press, Inc. Other product and company names mentioned herein may be the
trademarks of their respective owners. Rather than use a trademark symbol with
every occurrence of a trademarked name, we are using the names only in an
editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The information in this book is distributed on an “As Is” basis, without warranty.
While every precaution has been taken in the preparation of this work, neither the
author nor No Starch Press, Inc. shall have any liability to any person or entity with
respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in it.
To my wife Anna
About the Author
Acknowledgments
Introduction
Chapter 1: Python Refresher
Chapter 2: Python Tricks
Chapter 3: Data Science
Chapter 4: Machine Learning
Chapter 5: Regular Expressions
Chapter 6: Algorithms
Afterword
Index
CONTENTS IN DETAIL
ACKNOWLEDGMENTS
INTRODUCTION
Python One-Liner Example
A Note on Readability
Who Is This Book For?
What Will You Learn?
Online Resources
1
PYTHON REFRESHER
Basic Data Structures
Numerical Data Types and Structures
Booleans
Strings
The Keyword None
Container Data Structures
Lists
Stacks
Sets
Dictionaries
Membership
List and Set Comprehension
Control Flow
if, else, and elif
Loops
Functions
Lambdas
Summary
2
PYTHON TRICKS
Using List Comprehension to Find Top Earners
The Basics
The Code
How It Works
Using List Comprehension to Find Words with High
Information Value
The Basics
The Code
How It Works
Reading a File
The Basics
The Code
How It Works
Using Lambda and Map Functions
The Basics
The Code
How It Works
Using Slicing to Extract Matching Substring Environments
The Basics
The Code
How It Works
Combining List Comprehension and Slicing
The Basics
The Code
How It Works
Using Slice Assignment to Correct Corrupted Lists
The Basics
The Code
How It Works
Analyzing Cardiac Health Data with List Concatenation
The Basics
The Code
How It Works
Using Generator Expressions to Find Companies That Pay
Below Minimum Wage
The Basics
The Code
How It Works
Formatting Databases with the zip() Function
The Basics
The Code
How It Works
Summary
3
DATA SCIENCE
Basic Two-Dimensional Array Arithmetic
The Basics
The Code
How It Works
Working with NumPy Arrays: Slicing, Broadcasting, and
Array Types
The Basics
The Code
How It Works
Conditional Array Search, Filtering, and Broadcasting to
Detect Outliers
The Basics
The Code
How It Works
Boolean Indexing to Filter Two-Dimensional Arrays
The Basics
The Code
How It Works
Broadcasting, Slice Assignment, and Reshaping to Clean
Every i-th Array Element
The Basics
The Code
How It Works
When to Use the sort() Function and When to Use the argsort()
Function in NumPy
The Basics
The Code
How It Works
How to Use Lambda Functions and Boolean Indexing to Filter
Arrays
The Basics
The Code
How It Works
How to Create Advanced Array Filters with Statistics, Math,
and Logic
The Basics
The Code
How It Works
Simple Association Analysis: People Who Bought X Also
Bought Y
The Basics
The Code
How It Works
Intermediate Association Analysis to Find Bestseller Bundles
The Basics
The Code
How It Works
Summary
4
MACHINE LEARNING
The Basics of Supervised Machine Learning
Training Phase
Inference Phase
Linear Regression
The Basics
The Code
How It Works
Logistic Regression in One Line
The Basics
The Code
How It Works
K-Means Clustering in One Line
The Basics
The Code
How It Works
K-Nearest Neighbors in One Line
The Basics
The Code
How It Works
Neural Network Analysis in One Line
The Basics
The Code
How It Works
Decision-Tree Learning in One Line
The Basics
The Code
How It Works
Get Row with Minimal Variance in One Line
The Basics
The Code
How It Works
Basic Statistics in One Line
The Basics
The Code
How It Works
Classification with Support-Vector Machines in One Line
The Basics
The Code
How It Works
Classification with Random Forests in One Line
The Basics
The Code
How It Works
Summary
5
REGULAR EXPRESSIONS
Finding Basic Textual Patterns in Strings
The Basics
The Code
How It Works
Writing Your First Web Scraper with Regular Expressions
The Basics
The Code
How It Works
Analyzing Hyperlinks of HTML Documents
The Basics
The Code
How It Works
Extracting Dollars from a String
The Basics
The Code
How It Works
Finding Nonsecure HTTP URLs
The Basics
The Code
How It Works
Validating the Time Format of User Input, Part 1
The Basics
The Code
How It Works
Validating Time Format of User Input, Part 2
The Basics
The Code
How It Works
Duplicate Detection in Strings
The Basics
The Code
How It Works
Detecting Word Repetitions
The Basics
The Code
How It Works
Modifying Regex Patterns in a Multiline String
The Basics
The Code
How It Works
Summary
6
ALGORITHMS
Finding Anagrams with Lambda Functions and Sorting
The Basics
The Code
How It Works
Finding Palindromes with Lambda Functions and Negative
Slicing
The Basics
The Code
How It Works
Counting Permutations with Recursive Factorial Functions
The Basics
The Code
How It Works
Finding the Levenshtein Distance
The Basics
The Code
How It Works
Calculating the Powerset by Using Functional Programming
The Basics
The Code
How It Works
Caesar’s Cipher Encryption Using Advanced Indexing and
List Comprehension
The Basics
The Code
How It Works
Finding Prime Numbers with the Sieve of Eratosthenes
The Basics
The Code
How It Works
Calculating the Fibonacci Series with the reduce() Function
The Basics
The Code
How It Works
A Recursive Binary Search Algorithm
The Basics
The Code
How It Works
A Recursive Quicksort Algorithm
The Basics
The Code
How It Works
Summary
AFTERWORD
INDEX
ACKNOWLEDGMENTS
The world doesn’t need more books; it needs better books. I’m
incredibly grateful to the people at No Starch Press for putting
everything at work toward this philosophy. This book is the
result of their invaluable advice, constructive feedback, and
hundreds of hours of diligent work. My deep gratitude goes to
the No Starch team for making the book-writing process such
a fun experience.
In particular, I’d like to thank Bill Pollock for inviting me
to write this book and for providing me inspiration and deep
insights into the publishing world.
I’m very grateful for my brilliant content editor, Liz
Chadwick, who skillfully, patiently, and eloquently
transformed my rough drafts into a much more human-
readable form. It’s because of her excellent support that the
book reached a level of clarity I would have never imagined
when starting this project.
I want to express my appreciation to Alex Freed for her
relentless focus on improving the text quality. It has been an
honor to work together with such a talented editor.
I’d like to thank my production editor, Janelle Ludowise,
for polishing the book with a great love for every detail.
Janelle put her skills to work—in a positive and enthusiastic
manner—to craft the final version of the book. Thanks,
Janelle. Many thanks as well to Kassie Andreadis, who
energetically pushed the book through to completion.
My distinctive appreciation goes to Professor Daniel
Zingaro. He didn’t shy away from investing much of his time,
effort, and excellent computer science skills into eradicating
inaccuracies from the book. He also contributed many
wonderful suggestions that brought clarity to the book.
Without his effort, the book would not only contain more bugs
but also be harder to read. That said, any inaccuracies that
remain are my own.
My doctorate supervisor, Professor Rothermel, contributed
indirectly to this book by investing considerable time, skill,
and effort into my computer science education. I owe him my
deepest gratitude and appreciation.
I’m forever grateful to my beautiful wife, Anna Altimira,
who keeps listening to, encouraging, and supporting even my
wildest ideas. I’m also thankful to my kids, Amalie and
Gabriel, for their inspiring curiosity and the happiness they
bring to my life through thousands of smiles.
Lastly, the greatest source of motivation came from the
active members of the Finxter community. First and foremost,
I’ve written this book for ambitious coders—like you—who
want to advance their coding skills and solve practical
problems in the real world. After long working days, it was
grateful emails from Finxter members that encouraged me to
write more sections of the book.
INTRODUCTION
q = lambda l: q( ➊[x for x in l[1:] if x <= l[0]]) + [l[0]] + q([x for x in l if x > l[0]])
if l else []
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com