A Bill Splitter
Four friends, an $86.40 dinner and a 15% tip: everyone’s share in a few seconds, right every time.
Bill before tip: $86.40Tip: $12.96Total with tip: $99.36People: 4-------------------------------Each person pays: $24.84
Python for Beginners · by the Python For Beginners team
The Python book for complete beginners. Start from zero, learn to fix your own errors, and build four programs that do real jobs.
This is hello.py from Chapter 1. Run it, then change print on line 2 into pritn, as if your fingers had slipped, and run it again. Python tells you what’s wrong, where it is, and often how to fix it.
Python loads when you press Run
ctrl/⌘ + enter to run · real Python, running in your browser
What they built, fixed and kept using.
I had never written a line of code, and math was never my thing. By the end of Chapter 1 I had Python installed and my first program running, and when the installer did something odd, Appendix B had the exact fix.
Error messages used to make me close the laptop. Now I read them from the bottom up, find the line, change one thing and run it again. That habit alone made the book worth it.
I work full time, so I did one section most evenings after dinner. Each section is short enough to finish in one sitting, and I never felt lost when I picked the book up again.
The bill splitter was the first program I actually used. At a dinner with friends it worked out the tip and everyone’s share before anyone had found the calculator on their phone. It also explained why my first answer came out as 24.840000000000003.
I swapped the book’s categories for my own in the budget checker, and the report flagged eating out as over budget for the third month running. It’s the first budget I’ve actually kept up with.
I built the job application tracker while I was looking for work, then kept using it for my real applications. The follow-up reminder flagged two companies I’d forgotten to chase.
Every month I copied sales figures from three files into a spreadsheet by hand. My version of the report builder now does it in seconds, formatted and with the totals checked. That’s about three hours a month back.
My Downloads folder had years of clutter. The Chapter 14 program sorted it into folders, and I trusted it because it showed me its plan with a dry run before it moved a single file.
I didn’t expect a beginners’ book to teach testing. Now, whenever I change my report script, pytest tells me in a second whether the totals are still right.
Typing every example felt slow at first, but it’s why the code stuck. Working out the answer on paper before writing the program means I know when my program is right, not just when it runs.
Every chapter ends with a practice program, and the full solutions are at the back of the book and in the example files. I could try on my own first and still check my work at midnight without waiting for anyone.
I finished with four programs I actually use, and Appendix G gave me a clear next step. The budget project got me hooked on data, so I’ve started learning pandas.
Each part of the book ends with a project: one complete program that does a real job. You build it in four steps, and it runs after every one.
Four friends, an $86.40 dinner and a 15% tip: everyone’s share in a few seconds, right every time.
Bill before tip: $86.40Tip: $12.96Total with tip: $99.36People: 4-------------------------------Each person pays: $24.84
Log your spending as you go and see, category by category, where you stayed on track and where you went over.
groceries 343.45 300.00 114% <- over by 43.45eating out 168.90 150.00 113% <- over by 18.90Total 1,434.35 1,500.00 96%Over budget: groceries, eating out
Every application saved from one day to the next, and a flag when an employer has gone quiet for 10 days.
Applications on file: 4Follow-ups due: 2. Choose 4 to see them.Greenfield Library: no news for 14 daysCopperline Logistics: no news for 11 days
A bakery’s three shops send their sales files. Your program turns them into one formatted spreadsheet, archives them and tests the sums.
15 rows from 3 files.Sales by shop Harbour 6,534.60 Market 4,649.50 Station 5,447.20Total sales: 16,631.30
Each section adds one idea, shows it in a few lines of code and has you run it. These six come straight from the book, with the output they print.
print("Two coffees:", 2 * 2.80)
print("Three coffees:", 3 * 2.80)Two coffees: 5.6 Three coffees: 8.399999999999999
Three coffees at 2.80 come to 8.399999999999999. Nothing is broken, and Chapter 2 shows why, and how to round money.
age = int(input("How old are you? "))
if age < 12:
print("You get the child price.")
print("Your ticket costs $6.")
print("Enjoy the film!")How old are you? 8 You get the child price. Your ticket costs $6. Enjoy the film!
A child’s cinema ticket, free museum entry, free shipping from $50: your program picks the right path.
thickness = 0.1
everest = 8849000
folds = 0
while thickness < everest:
thickness = thickness * 2
folds = folds + 1
print("Folds needed:", folds)Folds needed: 27
How many folds until a sheet of paper is taller than Everest? A while loop finds out: 27.
prices = [2.49, 3.10, 0.99, 4.25]
total = 0
for price in prices:
total += price
print(f"Total: {total:.2f}")Total: 10.83
Keep a whole receipt in one list and let a loop total it, however long it gets.
def greet(name):
print(f"Hello, {name}!")
print("Nice to see you.")
greet("Ana")
greet("Tom")Hello, Ana! Nice to see you. Hello, Tom! Nice to see you.
Name a piece of work once, then run it as often as you like, with different information each time.
from datetime import date, timedelta
today = date(2026, 10, 19)
holiday = date(2026, 12, 24)
wait = holiday - today
print(wait.days, "days to go")66 days to go
Subtract one date from another and Python counts the days for you, leap years included.
Everyone gets them, every day. Chapter 3 teaches you to read one from the bottom up, find the mistake and fix it, calmly and in the same order every time.
print("Welcome to the cafe")
print("One coffee costs 2.50")
Print("Two coffees cost 5.00")
$ python cafe.pyWelcome to the cafeOne coffee costs 2.50Traceback (most recent call last): File "/home/sam/python_book/cafe.py", line 3, in <module> Print("Two coffees cost 5.00") ^^^^^NameError: name 'Print' is not defined. Did you mean: 'print'?
Read the error message from the bottom. The last line names the problem, and the File line tells you which line of your program to check.
Compare your code with the book’s, character by character. Most mistakes hide in quote marks, brackets, colons, capital letters, and spaces at the start of lines.
Run the book’s version from the example files. If it works and yours doesn’t, the difference is in your typing.
Take a break. Ten minutes away often turns an impossible problem into an obvious one.
Ask the right way. Chapter 3 shows how to use the documentation, forums and AI assistants without skipping the learning.
15 chapters, 4 projects and 7 appendices: 310 pages from installing Python to building a formatted spreadsheet report. Every chapter ends with a Practice exercise, solved in Appendix E.
Put Python on your computer and run a program of your own, starting from zero.
See how Python treats numbers and text, until the shell is the most patient calculator you own.
Read an error from the bottom up, find the mistake and fix it, in the same order every time.
Give values names, drop them into sentences and let the user type their own answers.
Four friends, an $86.40 dinner bill and a 15% tip: each person's share in a few seconds.
Uses Chapters 1–4. The program runs after every step and does a little more each time.
Ask yes-or-no questions about a value, choose what runs next and survive unexpected input.
Count, add things up, keep a menu on screen and keep asking until the answer makes sense.
Keep a whole group of values together: add, change, sort and go through them.
Store information under names, look it up, count things and describe records.
Set a budget for rent, groceries, transport, eating out and fun, then see where you went over.
Uses Chapters 5–8. The program runs after every step and does a little more each time.
Name a piece of work once and reuse it, so a program reads like a table of contents.
Use Python's toolbox, split your own code into files and install free packages.
Programs that remember: read, write and save data so it is still there tomorrow.
Read CSV files from your bank or fitness app, filter and add up rows, save a new file.
Records, a menu, functions, dates and a saved file in one program that flags what needs a follow-up.
Uses Chapters 9–12. The program runs after every step and does a little more each time.
Write small pieces of code that check your code, and run them in a second.
Sort a messy Downloads folder in a second, and show a plan before touching a single file.
Read Excel files, write new ones, add formulas and format a report people want to read.
A bakery with three shops: their monthly sales files become one formatted spreadsheet, archived safely, with tests.
Uses Chapters 13–15. The program runs after every step and does a little more each time.
Read it in order: every chapter uses only what came before it.
Each section shows a short program and the output it prints, then explains it. Sections are short, so you can stop at the end of any one.
Typing trains your eyes, gives you small mistakes to fix and makes the code yours. The example files are there to check against, not to copy.
Every chapter ends with a program to write on your own, with the result to aim for and a couple of hints. Appendix E has a worked solution for each.
Each project grows in four steps, and your program runs after every one. If something breaks, you only look at what you just changed.
Real pages from the book: short sections, the code you type and the exact output you should see.
Everything you get, before you pay.
python-for-beginners.pdf
look insidepython-for-beginners/├── intro/│ └── hello.py the example from this introduction├── ch01/ … ch15/ one folder for each chapter├── p1/ … p4/ one folder for each project└── solutions/ the programs from Appendix E
Python For Beginners
Python For Beginners is a team of Python experts with one goal: helping complete beginners learn PythonThe programming language this book teaches. The program that runs your code is called Python too.. This book is how we do it: a Python book for beginners that starts from zero and ends with four programA list of instructions, written in order, that a computer follows to get a result. that do real jobs.
We wrote it the way we’d want to learn. Every chapter uses only what came before it, every section shows the codeThe text you write to give a computer instructions. before it explains it, and a 269-term glossary catches any word you forget. Every example was run on Python 3.12 or later, and the outputWhat a program shows on the screen when it runs. In this book it’s printed on a black panel. on the page is copied from those runs, not typed by hand.
Getting stuck is part of learning, so the book plans for it.
Everything you need to keep going is in the book.
About the book, the example files and buying it.
Yes. It’s written for adults who have never written a line of code. If you can use a web browser, save a file and find it again later, you know enough to start. Each chapter builds only on the ones before it.
No. Nothing in the book needs more than everyday arithmetic: adding, subtracting, multiplying and dividing.
A desktop or laptop running Windows, macOS or Linux (the book is written for a computer, not a tablet or phone), and regular short sessions. Chapter 1 walks you through installing Python, and Appendix B covers the problems people hit most often.
A 310-page PDF and a ZIP of example files: every program in the book, each project as it stands after every step, the data files the examples read, and the solutions from Appendix E. The PDF opens on any phone, tablet or computer, and you can print it.
Python 3.12 or later. Every example was run on Python 3.12 or later, and the output you see is copied from those runs. Newer versions may word a few error messages slightly differently, which is normal.
Because you still need to know whether the code is right. Section 3.5 shows you how to use an AI assistant as a tutor: ask it to explain an error, not only to fix it, and check its answer by running it, because an assistant can sound sure and still be wrong.
Right after payment your downloads are ready on the confirmation page, and Polar emails you a receipt with a link to your library.
Yes. Open your Polar library with the email you used to buy, enter the one-time code it sends you, and download the PDF and the example files again. There’s a link in the footer.
Because the files are delivered instantly, you agree at checkout to immediate access and lose the 14-day right of withdrawal once they’re available. If a file is faulty, not as described, or you were charged twice, you’re still covered: see the refund policy.
Checkout is handled by Polar, our merchant of record. You can pay by card, and in some countries with local methods such as iDEAL or Bancontact. PayPal is not available. Polar calculates any VAT or sales tax for your country and emails you an invoice.
Still unsure? Run Chapter 1 above, or look inside the book.
Learn to read what Python tells you, fix it yourself, and finish with four programs that do real jobs.