__Doing Math with Python__ shows you how to use Python to delve into high school—level math topics like statistics, geometry, probability, and calculus. You'll start with simple projects, like a factoring program and a quadratic-equation solver, and then create more complex projects once you've gotten the hang of things. Along the way, you'll discover new ways to explore math and gain valuable programming skills that you'll use throughout your study of math and computer science. Learn how to: * Describe your data with statistics, and visualize it with line graphs, bar charts, and scatter plots * Explore set theory and probability with programs for coin flips, dicing, and other games of chance * Solve algebra problems using Python's symbolic math functions * Draw geometric shapes and explore fractals like the Barnsley fern, the Sierpinski triangle, and the Mandelbrot set * Write programs to find derivatives and integrate functions Creative coding challenges and applied examples help you see how you can put your new math and coding skills into practice. You'll write an inequality solver, plot gravity's effect on how far a bullet will travel, shuffle a deck of cards, estimate the area of a circle by throwing 100,000 "darts" at a board, explore the relationship between the Fibonacci sequence and the golden ratio, and more.Whether you're interested in math but have yet to dip into programming or you're a teacher looking to bring programming into the classroom, you'll find that Python makes programming easy and practical. Let Python handle the grunt work while you focus on the math. Brief Contents Contents in Detail Acknowledgments Introduction Who Should Read This Book What’s in This Book? Scripts, Solutions, and Hints Chapter 1: Working with Numbers Basic Mathematical Operations Labels: Attaching Names to Numbers Different Kinds of Numbers Working with Fractions Complex Numbers Getting User Input Handling Exceptions and Invalid Input Fractions and Complex Numbers as Input Writing Programs That Do the Math for You Calculating the Factors of an Integer Generating Multiplication Tables Converting Units of Measurement Finding the Roots of a Quadratic Equation What You Learned Programming Challenges Challenge 1: Even-Odd Vending Machine Challenge 2: Enhanced Multiplication Table Generator Challenge 3: Enhanced Unit Converter Challenge 4: Fraction Calculator Challenge 5: Give Exit Power to the User Chapter 2: Visualizing Data with Graphs Understanding the Cartesian Coordinate Plane Working with Lists and Tuples Iterating over a List or Tuple Creating Graphs with Matplotlib Marking Points on Your Graph Graphing the Average Annual Temperature in New York City Comparing the Monthly Temperature Trends of New York City Customizing Graphs Saving the Plots Plotting with Formulas Newton’s Law of Universal Gravitation Projectile Motion What You Learned Programming Challenges Challenge 1: How Does the Temperature Vary During the Day? Challenge 2: Exploring a Quadratic Function Visually Challenge 3: Enhanced Projectile Trajectory Comparison Program Challenge 4: Visualizing Your Expenses Challenge 5: Exploring the Relationship Between the Fibonacci Sequence and the Golden Ratio Chapter 3: Describing Data with Statistics Finding the Mean Finding the Median Finding the Mode and Creating a Frequency Table Finding the Most Common Elements Finding the Mode Creating a Frequency Table Measuring the Dispersion Finding the Range of a Set of Numbers Finding the Variance and Standard Deviation Calculating the Correlation Between Two Data Sets Calculating the Correlation Coefficient High School Grades and Performance on College Admission Tests Scatter Plots Reading Data from Files Reading Data from a Text File Reading Data from a CSV File What You Learned Programming Challenges Challenge 1: Better Correlation Coefficient–Finding Program Challenge 2: Statistics Calculator Challenge 3: Experiment with Other CSV Data Challenge 4: Finding the Percentile Challenge 5: Creating a Grouped Frequency Table Chapter 4: Algebra and Symbolic Math with SymPy Defining Symbols and Symbolic Operations Working with Expressions Factorizing and Expanding Expressions Pretty Printing Substituting in Values Converting Strings to Mathematical Expressions Solving Equations Solving Quadratic Equations Solving for One Variable in Terms of Others Solving a System of Linear Equations Plotting Using SymPy Plotting Expressions Input by the User Plotting Multiple Functions What You Learned Programming Challenges Challenge 1: Factor Finder Challenge 2: Graphical Equation Solver Challenge 3: Summing a Series Challenge 4: Solving Single-Variable Inequalities Chapter 5: Playing with Sets and Probability What’s a Set? Set Construction Subsets, Supersets, and Power Sets Set Operations Probability Probability of Event A or Event B Probability of Event A and Event B Generating Random Numbers Nonuniform Random Numbers What You Learned Programming Challenges Challenge 1: Using Venn Diagrams to Visualize Relationships Between Sets Challenge 2: Law of Large Numbers Challenge 3: How Many Tosses Before You Run Out of Money? Challenge 4: Shuffling a Deck of Cards Challenge 5: Estimating the Area of a Circle Chapter 6: Drawing Geometric Shapes and Fractals Drawing Geometric Shapes with Matplotlib’s Patches Drawing a Circle Creating Animated Figures Animating a Projectile’s Trajectory Drawing Fractals Transformations of Points in a Plane Drawing the Barnsley Fern What You Learned Programming Challenges Challenge 1: Packing Circles into a Square Challenge 2: Drawing the Sierpinski Triangle Challenge 3: Exploring Hénon’s Function Challenge 4: Drawing the Mandelbrot Set Chapter 7: Solving Calculus Problems What Is a Function? Domain and Range of a Function An Overview of Common Mathematical Functions Assumptions in SymPy Finding the Limit of Functions Continuous Compound Interest Instantaneous Rate of Change Finding the Derivative of Functions A Derivative Calculator Calculating Partial Derivatives Higher-Order Derivatives and Finding the Maxima and Minima Finding the Global Maximum Using Gradient Ascent A Generic Program for Gradient Ascent A Word of Warning About the Initial Value The Role of the Step Size and Epsilon Finding the Integrals of Functions Probability Density Functions What You Learned Programming Challenges Challenge 1: Verify the Continuity of a Function at a Point Challenge 2: Implement the Gradient Descent Challenge 3: Area Between Two Curves Challenge 4: Finding the Length of a Curve Afterword Things to Explore Next Project Euler Python Documentation Books Getting Help Conclusion Appendix A: Software Installation Microsoft Windows 7 Installing SymPy Installing matplotlib-venn Starting the Python Shell Linux Updating SymPy Installing matplotlib-venn Starting the Python Shell Mac OS X Updating SymPy Installing matplotlib-venn Starting the Python Shell Appendix B: Overview of Python Topics if __name__ == '__main__' List Comprehensions Dictionary Data Structure Multiple Return Values Exception Handling Specifying Multiple Exception Types The else Block Reading Files in Python Reading All the Lines at Once Specifying the Filename as Input Handling Errors When Reading Files Reusing Code Index Resources More No-nonsense Books from No Starch Press! About the Author Doing Math with Python shows you how to use Python to delve into high school–level math topics like statistics, geometry, probability, and calculus. You'll start with simple projects, like a factoring program and a quadratic-equation solver, and then create more complex projects once you've gotten the hang of things.Along the way, you'll discover new ways to explore math and gain valuable programming skills that you'll use throughout your study of math and computer science. Learn how to:–Describe your data with statistics, and visualize it with line graphs, bar charts, and scatter plots–Explore set theory and probability with programs for coin flips, dicing, and other games of chance–Solve algebra problems using Python's symbolic math functions–Draw geometric shapes and explore fractals like the Barnsley fern, the Sierpinski triangle, and the Mandelbrot set–Write programs to find derivatives and integrate functionsCreative coding challenges and applied examples help you see how you can put your new math and coding skills into practice. You'll write an inequality solver, plot gravity's effect on how far a bullet will travel, shuffle a deck of cards, estimate the area of a circle by throwing 100,000'darts'at a board, explore the relationship between the Fibonacci sequence and the golden ratio, and more.Whether you're interested in math but have yet to dip into programming or you're a teacher looking to bring programming into the classroom, you'll find that Python makes programming easy and practical. Let Python handle the grunt work while you focus on the math.Uses Python 3 Doing Math With Python Shows You How To Use Python To Delve Into High School–level Math Topics Like Statistics, Geometry, Probability, And Calculus. You’ll Start With Simple Projects, Like A Factoring Program And A Quadratic-equation Solver, And Then Create More Complex Projects Once You’ve Gotten The Hang Of Things. Along The Way, You’ll Discover New Ways To Explore Math And Gain Valuable Programming Skills That You’ll Use Throughout Your Study Of Math And Computer Science. Learn How To: -describe Your Data With Statistics, And Visualize It With Line Graphs, Bar Charts, And Scatter Plots -explore Set Theory And Probability With Programs For Coin Flips, Dicing, And Other Games Of Chance -solve Algebra Problems Using Python’s Symbolic Math Functions -draw Geometric Shapes And Explore Fractals Like The Barnsley Fern, The Sierpinski Triangle, And The Mandelbrot Set -write Programs To Find Derivatives And Integrate Functions Creative Coding Challenges And Applied Examples Help You See How You Can Put Your New Math And Coding Skills Into Practice. You’ll Write An Inequality Solver, Plot Gravity’s Effect On How Far A Bullet Will Travel, Shuffle A Deck Of Cards, Estimate The Area Of A Circle By Throwing 100,000 “darts” At A Board, Explore The Relationship Between The Fibonacci Sequence And The Golden Ratio, And More. Whether You’re Interested In Math But Have Yet To Dip Into Programming Or You’re A Teacher Looking To Bring Programming Into The Classroom, You’ll Find That Python Makes Programming Easy And Practical. Let Python Handle The Grunt Work While You Focus On The Math. In Doing Math with Python you'll learn to how to use the Python programming language as a tool to delve into math concepts. Python is easy to learn, and it's perfect for exploring topics like statistics, geometry, probability, and calculus. Youll learn to write programs to find derivatives, solve equations graphically, manipulate algebraic expressions, even examine projectile motion. Rather than crank through tedious calculations by hand, you'll learn how to use Python functions and modules to handle the number crunching while you focus on the principles behind the math. Exercises throughout teach fundamental programming concepts, like using functions, handling user input, and reading and manipulating data. As you learn to think computationally, you'll discover new ways to explore and think about math, and gain valuable programming skills that you can use to continue your study of math and computer science. If youre interested in math but have yet to dip into programming, youll find that Python makes it easy to go deeper into the subjectlet Python handle the tedious work while you spend more time on the math. Summary: "Uses the Python programming language as a tool to explore high school-level mathematics like statistics, geometry, probability, and calculus by writing programs to find derivatives, solve equations graphically, manipulate algebraic expressions, and examine projectile motion. Covers programming concepts including using functions, handling user input, and reading and manipulating data"-- Provided by publisher. Includes index. "Uses the Python programming language as a tool to explore high school level mathematics like statistics, geometry, probability, and calculus by writing programs to find derivatives, solve equations graphically, manipulate algebraic expressions, and examine projectile motion. Covers programming concepts including using functions, handling user input, and reading and manipulating data"-- Provided by publisher Numbers Visualizing data with graphs Describing data with statistics Algebra and symbolic math with SymPy Sets and probability Drawing geometric shapes and fractals Working with mathematical functions Appendix A: Setup, installation, and resources Appendix B: Python functionality Appendix C: Solutions.