Python Can Be Your Calculator

There’s a ton of things that you can do with Python and you’ll learn many of them in this course. But before we dive into complex subjects, let’s have some fun with another simple task that you can do with Python. We are going to make Python our calculator.

Let’s start with something easy. So 4 plus 5 is 9, 9 times 7 is 63, minus 1 divided by 4 is minus 0.25. Easy. Repeating or periodic numbers are printed in a longer format. Let’s try 1 divided by 3. In math theory, when 1 is divided by 3, the digit 3 repeats forever after the decimal point. Of course, it’s hard to display something that repeats for ever. So instead, we have a representation showing lots of decimal places. Not too hard, right?

Let’s get the computer something a bit trickier. Let’s say we want to divide 2050 by 5, then subtract 32 and then divide the result by 9. To do this, we’ll need to use parentheses, just as we do in typical math problems. You can also use Python to get squares, cubes, or any power of n of a number. For example, let’s say we want to find out what 2 to the power of 10 is. To get Python to give us the answer, we use the double star operator.

If you’re starting to worry that this is becoming an algebra course, relax. We’re not going to do anything more complex than what we’ve just seen. If you’re thinking, «Why would I use Python instead of just a normal calculator?» That’s a valid question. Experimenting in this way, you get familiar with the language’s math capabilities. In IT jobs, there are many tasks that require you to use math calculations.

You might need to count how many times a certain word appears in a text, or work out the average time it takes for an operation to complete, or how much you have to compress an image to fit in certain size constraints. Whatever you need to calculate, writing a script can help you do it faster and with more accuracy. So you need to know what mathematical operations are available to you.

Python actually has a lot more advanced numeric capabilities that are used for data analysis, statistics, machine learning, and other scientific applications. We won’t get into these in this course. But if you want to learn more about them on your own, there’s a wealth of online resources available. Next up, a cheat sheet to help you with programming concepts that we’ve just covered. After that, it’s time for another quiz. This time with a few small coding exercises.

Remember, if something is unclear, you can re-watch the videos as many times as you need. Ready? You’ve got this.

Previous
Coding - 002
Cursos
Python I - Unit 01
Python
Introduction to Programming
Specialization Introduction 1 points
Welcome to the Course! 1 points
Course Introduction 1 points
Beginning Your Programming Journey 1 points
What is Programming? 1 points
Quiz - 001 10 points 3m
What is Automation? 1 points
Quiz - 002 3m
Computers Working for You Preview 1 points
Quiz - 003 3m
Test - 01 10m
Introduction to Python
What is Python? 1 points
Quiz - 004 5m
A Note on Syntax and Code Blocks 1 points
Why is Python relevant to IT? 1 points
More About Python 1 points
Other Languages 1 points
PythonAnyware SignUp 1 points
First PythonAnyware code Preview 1 points
Test - 02 15m
Hello World
Hello, World! 1 points
Coding - 001 15m
Getting Information from the User 1 points
Coding - 002 10m
Coding - 003 10m
First Programming Concepts 1 points
Test - 03 15m
Module Review
First Steps Wrap Up 1 points
Assessment - 01a 15m
Meet Marga, the Curriculum Developer 1 points
Assessment - 01b 30m
Visit the Week I forum and say hello 1 points