Change language

Python Workout: 50 TEN-MINUTE EXERCISES

$50

Python Workout: 50 TEN-MINUTE EXERCISES REUVEN LERNER

Python Workout isn not designed to teach you Python, although I hope and expect that you will learn quite a bit along the way. It is meant to help you improve your understand- ing of Python and how to use it to solve problems. You can think of it as a workbook, one whose power and learning potential depends on you. The more effort you put into this book, the more you’ll get out of it.

So you've decided to become a programmer. We recently created a beginner help group, and now we're going to show you what it takes to join the Python testers league. The post was written by two people, so it may have turned out to be a little messy.

First, a few general questions about Python testing.

Python Workout PDF: What does a tester do?

Tests programs. His task is to catch all possible errors at every stage of the life of a software product.

Python Workout: How much does a tester earn?

Usually testers get slightly fewer programmers, salaries start at thirty thousand and end well over a hundred. Depends on your experience (read positions - Junior, Middle, Senior, Expert), the level of salary in the company and in your city).

Python Workout: Is there space to grow?

Testers and test developers have the opportunity to grow, because test development is also the development of a software product, often as complex as the product itself.

You can go in different directions - in test management, develop expertise and become a highly paid specialist (although not a manager), you can go into pure development.

It won't work. The labor market is overflowing with people who think the same way. Unfortunately, such people are not in high demand in the market. When an intern or junior is hired, it is expected that his skills will grow significantly in the foreseeable future, and he will no longer have to spend resources on his training, on the contrary, he will have to bring benefits to the company. Moreover, it is also in your interests (as an intern) - by becoming a more experienced and valuable specialist, you can apply for a higher position and pay.

Reuven M. Lerner is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China, as well as to individuals around the world, via online courses. He blogs and tweets (@reuvenmlerner) frequently about Python and is a panelist on the Business of Freelancing podcast. Reuven lives in Modi’in, Israel with his wife and three children. You can learn more about Reuven at https://lerner.co.il/

>Python workout: 50 ten-minute exercises

It's okay when it doesn't work either the first or the tenth time. It's okay to google it all the time, google it, and debug it over and over again. It's okay when it seemed like it was easy on the course, and then PRACTICE catches up with you and real self-study begins through suffering. But then you understand it properly and understand that in fact after the course there was only a vague idea.

All of the above is completely serious. You have to be mentally prepared for this, so as not to be disappointed. A lot of people buy into beautiful advertising of courses, and then give up, because, it turns out, despite the fact that everyone said that python is simple, their brains need to be strained very much.

Python is indeed more readable than many other languages ​​and is relatively easy to learn at the beginner (!!) level. However, complex algorithms or complex systems will be difficult to write in any language.

Who should read this book

This book is aimed at developers who have taken a Python course, or perhaps read an introductory book on the language. Indeed, the bulk of these exercises are aimed at people who are in my intro Python course, or who have recently finished taking it. You should already have an understanding of basic constructs, such as if and for, as well as the core data structures, such as strings, lists, tuples, and dictionaries.

But there’s a difference between having a passing familiarity with these topics and knowing how to apply them to actual problems. If you can get by with Python but find yourself going to Stack Overflow many times each day, then this book will help you to become more confident and independent as you write Python code. I’d argue that if you have been using Python regularly for less than six months, then you’ll gain from this book.

How this book is organized: a roadmap

This book has ten chapters, each focusing on a different aspect of Python. However, the exercises in each chapter will use techniques from other chapters. For example, nearly every exercise asks you to write a function or a class, even though functions are introduced in chapter 6 and classes are introduced in chapter 9. Think of the names as general guidelines, rather than strict rules, for what you’ll be practicing and learning in each chapter.

Preface

In many ways, learning a programming language is like learning a foreign (human) language. You can take a course, understand the subject, and even do well on the final exam. But when it comes time to actually use the language, you can find yourself flustered, unsure of just what syntax to use, or what’s the most appropriate way to phrase something—let alone be unable to understand native speakers.

That’s where practice comes in. Practicing a foreign language gives you greater fluency and confidence, allowing you to engage in deeper and more interesting conversations. Practicing Python allows you to solve problems more quickly and easily, while simultaneously writing more readable and maintainable code. The improvement happens over time, as you use the language in new and varied situations. It often isn’t obvious that you have improved. And yet, when you look back to how you were using the language just a few months before, the difference is stark.

This book isn’t meant to teach you Python. Rather, it’s meant to give you the practice you need to achieve greater fluency. After going through the exercises in this book—not just skimming through the questions and peeking at the answers—you will write more readable, more idiomatic, and more maintainable Python code. Python Workout is the result of conversations with students in my corporate Python training classes. Once the course was over, they often asked where they could get additional practice, to continue improving their skills. This book draws upon the hands-on labs that I give my students, as well as discussions that I have had with them during and after class.

The exercises are designed to help you internalize some of the core ideas in Python: core data structures, functions, comprehensions, object-oriented programming, and iterators. These might seem like simple topics, perhaps even too simple for a book of exercises. But all of Python, from the largest application to the smallest script, is based on these building blocks. Knowing them well is a crucial part of being a fluent Python developer. I often say that ignoring these building blocks in favor of more complex topics is akin to a chemistry student ignoring the elements in favor of “real” chemicals.

I can personally attest to the power of practice, not just as a Python instructor, but also as a student. For several years, I’ve been learning Chinese, in no small part because I travel to China every few months to teach Python courses there. Each lesson that I take, and every exercise that I do, doesn’t seem to advance my fluency very much. But when I return to China after an absence of several months, I find that the practice has indeed helped, and that I’m able to communicate more easily with the locals.

I’m still far from fluent in Chinese, but I’m making progress, and I delight in looking back and seeing how far I’ve come. I hope and expect that Python Workout will do the same for you, advancing your understanding and fluency with each passing day.

Numeric types

Whether you’re calculating salaries, bank interest, or cellular frequencies, it’s hard to imagine a program that doesn’t use numbers in one way or another. Python has three different numeric types: int, float, and complex. For most of us, it’s enough to know about (and work with) int (for whole numbers) and float (for numbers with a fractional component).

Numbers are not only fundamental to programming, but also give us a good introduction to how a programming language operates. Understanding how variable assignment and function arguments work with integers and floats will help you to reason about more complex types, such as strings, tuples, and dicts.

This chapter contains exercises that work with numbers, as inputs and as outputs. Although working with numbers can be fairly basic and straightforward, converting between them, and integrating them with other data types, can sometimes take time to get used to.

EXERCISE 1 ■ Number guessing game

This first exercise is designed to get your fingers warmed up for the rest of the book. It also introduces a number of topics that will repeat themselves over your Python career: loops, user input, converting types, and comparing values.

More specifically, programs all have to get input to do something interesting, and that input often comes from the user. Knowing how to ask the user for input not only is useful, but allows us to think about the type of data we’re getting, how to convert it into a format we can use, and what the format would be.

As you might know, Python only provides two kinds of loops: for and while. Knowing how to write and use them will serve you well throughout your Python career. The fact that nearly every type of data knows how to work inside of a for loop makes such loops common and useful. If you’re working with database records, elements in an XML file, or the results from searching for text using regular expressions, you’ll be using for loops quite a bit.

Reviews

Christine, Paris Gradual presentation of the material. Available. It's clear. There are examples. Quite a lot of interesting topics are covered.

Rahj_Sov, New Delhi There is no room for more in-depth study within this book. But for the price for which he took the book, this is impossible.

Joe023, New York I got to know Python from this book. Which I am glad. In addition to Python itself, you can learn some of the general principles of programming. Very little code is required to create workable and usable applications. Many examples are quickly corrected to suit their needs. I liked the book so much that I decided to study Python in more depth, for which I ordered several more books on Python.

Amanda, Missisipi As a person who has never studied programming, I decided to start with this book. And it is not suitable for a beginner. Compared to Michael Dawson's Programming in Python. In the book, Sveigart throws all the loops and conditions into one chapter at once, fluently talking about them, and immediately shows the code, which is very confused and incomprehensible to the reader. It also happens in general with the entire book, when the author can safely use terms of meaning that you do not even know. Of course, he explains some of them, but some of the material remains undigested. And if you think more about the beauty of the display of your code, and not about the code itself, and if the easy ways are not for you, then the book is recommended to read!

Python workout book reviews

The only way to gain mastery of any skill is to practice. Author Reuven M.Lerner guides you through 50 carefully chosen exercises that encourage you to flex your programming muscle. As you tackle each new challenge, you’ll develop programming skills and confidence. The clear explanations help you grasp what you’ve learned and apply it to real-world problems. Programming Workout offers over four hours of video training walking you through the solutions for each exercise and dozens of supplemental challenges for you to try on the fly.

Whenever I finish giving Python training, my students often ask: "What comes next?" "How can we continue to improve?" The answer? Practice. Like any skill, learning Python requires practice. To get better at writing Python, you need to practice writing Python. So, if you want to improve your Python skills, you should start practicing right now! The "Python Workout" includes 50 exercises that I've written over the years. In doing these exercises, you'll develop your Python fluency. By being able to read and write Python code more easily, you'll be able to write cleaner, more maintainable, and more Pythonic code. And, because you'll understand how Python actually works, you'll be able learn about new features and libraries without having to struggle too much.

This book contains not just the exercises and detailed solutions (which include step-by-step instructions), but also walk-through videos of me solving the exercises (and explaining what I'm doing along the way). You can watch those videos directly on the book's website, or download them to view offline later.And, I've included additional questions that you can try out after completing the core exercises in the book. These questions aren't part of the official curriculum, but they're fun to play around with, and they'll give you an opportunity to see how you're progressing.So, go ahead and pick up a copy of "Python Workout", and start practicing today!

Review by Steph06

This book is exceptionally engaging and offers absolute gems for beginners and experts alike. The book brilliantly engages learners tricking them into loving learning:) My favourite part of the book pertain to the deep insights that were methodically offered with each exercise. These are the type of insights that take one to an intermediate level skill level expert.

Review by waszczewski

I like to apply theories I learn, and this books offers what I need while learning. First: I read the task, and try to solve it my way, second: I compare my solutions with author's solutions, third: I complete all additional exercises.

Review by Richard

This book will help guide you through your journey. It's an extremely crafted resource for anyone wanting to master, practice, and develop their skills in Python. It's really 200 lessons, not just 50, so Reuven's brilliance and passion will rub off along the way. I love this book!

Review by Shai R.

This book is awesome! It is clear and to-the-point, yet thorough and effective! I often find it difficult to take a break and do the recommended practices that accompany educational books and videos (regardless of whether or not the topic is computer programming related). The fact that the exercises are front and center really helped motivate me to practice concepts covered and had fun with these practice exercises. I went through the book once doing all of the exercise and some of the bonus problems and will be going through the book again doing the rest of them. I learned a lot that was new to me, and felt more confident and better about my knowledge of the topics I already knew.

Mark Meyer

It's really a great book. Very well written, it contains lots of useful information about Python that I didn't know before, and I've been learning Python for four years now. I'm pretty sure you'll learn a lot and be amazed. And the little problems aren't ever too big or too difficult, which I appreciate immensely!

anon

The exercises are very clear and useful for those who want to practice the basic aspects of the language. I have several years of experience as a software developer (C ++, PHP, MySQL, and R) and this book has helped me get productive with Python quickly.

Tim Y

Learning by doing is always the best way to learn, and this book teaches Python through the exercises. The explanations of the solution are clear, very easy to understand.

Reuven is a master and really knows his python. In addition, in over 10 years of teaching, he has found that the exercises help his students learn more. And that's what this book is full of: the exercises. In other words, this book will help you learn Python faster than most other books.

Alex Carter

I really enjoyed going through each of Reuven's 50 exercises. I think there were only 2 exercises that I had to cheat on because I was a little nervous. The good news is that Reuven has great explanations of the solutions both in writing and in his videos. This book gave me the confidence to tackle Python projects that I previously thought would be out of my league.

Python Workout strengthens many of the basic Python skills that anyone who wants to become a Python expert will need. I am grateful that there are experienced professionals who write such books; it really helps the general public improve their Python skills.

I can't wait for Reuven's next book on Python (in case he decides to write another book).

PS To get the most out of this book, try to understand the reasoning and logic that were used to arrive at the solution. We'll always have to look for the documentation for the sake of clarity, but the basic concepts are the key points. Always try to find your solution before checking Reuven's solution.

Stephen Godfrey

What I liked most about this book is that the exercises were perfect. They were engaging, interesting, and at times funny (I didn't know there was an Ubbi-Dubbi language before I read this book). Best of all, all of the answers are included in the screencast (instructions in the book). So if you're really stuck, they'll go through you line by line.

If you're looking to take your Python programming skills to the next level, this book is for you. Buy it and you will become a better programmer for it.

Bart Willems

While the book focuses on basic problems, most of the exercises will be of use to even the most experienced Python programmer. Even if you * think * about writing "Pythonic" code, Reuven shows that there is usually a way to make things even shorter and cleaner. The exercises focus on being short but are always accompanied by a "Beyond Exercise" section with tips for additional exercises if you wish. Finally, the book has a light-hearted tone that makes it easy to digest, even if you are tired after a day of work. If you're not in the mood to work on a heavy 500-page tome but still want to learn something, this is a great alternative.

Contents


EXERCISE 1 ■ Number guessing game
EXERCISE 2 ■ Summing numbers
EXERCISE 3 ■ Run timing
EXERCISE 4 ■ Hexadecimal output
EXERCISE 5 ■ Pig Latin
EXERCISE 6 ■ Pig Latin sentence
EXERCISE 7 ■ Ubbi Dubbi
EXERCISE 8 ■ Sorting a string
EXERCISE 9 ■ First-last
EXERCISE 10 ■ Summing anything
EXERCISE 11 ■ Alphabetizing names
EXERCISE 12 ■ Word with most repeated letters
EXERCISE 13 ■ Printing tuple records
EXERCISE 14 ■ Restaurant
EXERCISE 15 ■ Rainfall
EXERCISE 16 ■ Dictdiff
EXERCISE 17 ■ How many different numbers?
EXERCISE 18 ■ Final Line
EXERCISE 19 ■ /etc/passwd to dict
EXERCISE 20 ■ Word count
EXERCISE 21 ■ Longest word per file
EXERCISE 22 ■ Reading and writing CSV
EXERCISE 23 ■ JSON
EXERCISE 24 ■ Reverse Lines
EXERCISE 25 ■ XML generator
EXERCISE 26 ■ Prefix notation calculator
EXERCISE 27 ■ Password generator
EXERCISE 28 ■ Join numbers
EXERCISE 29 ■ Add numbers
EXERCISE 30 ■ Flatten a list
EXERCISE 31 ■ Pig Latin translation of a file
EXERCISE 32 ■ Flip a dict
EXERCISE 33 ■ Transform values
EXERCISE 34 ■ (Almost) supervocalic words
EXERCISE 35a ■ Gematria, part 1
EXERCISE 35b ■ Gematria, part 2
EXERCISE 36 ■ Sales tax
EXERCISE 37 ■ Menu
EXERCISE 38 ■ Ice cream scoop
EXERCISE 39 ■ Ice cream bowl
EXERCISE 40 ■ Bowl limits
EXERCISE 41 ■ A bigger bowl
EXERCISE 42 ■ FlexibleDict
EXERCISE 43 ■ Animals
EXERCISE 44 ■ Cages
EXERCISE 45 ■ Zoo
EXERCISE 46 ■ MyEnumerate
EXERCISE 47 ■ Circle
EXERCISE 48 ■ All lines, all files
EXERCISE 49 ■ Elapsed since
EXERCISE 50 ■ MyChain

See also

Learn programming in R: courses

$FREE

Best Python online courses for 2022

$FREE

Best laptop for Fortnite

$399+

Best laptop for Excel

$