Updated: May 11
Have You Ever Wondered…
How does a calculator work?
When was the calculator invented?
How big were the first calculators?
How to make my own simple Calculator using Python Code.
Well, Let’s Answer each of the questions one by one!
Some Common FAQ’S:
What a calculator is made of?
Mechanical calculators (ones made from gears and levers) were in widespread use from the late-19th to the late-20th century. That’s when the first affordable, pocket, electronic calculators started to appear, thanks to the development of silicon microchips in the late 1960s and early 1970s.
Who invented the calculator and what year?
Willhelm Schickard invented the “Calculating Clock”, the first mechanical calculator. It used a version of Napier’s bones for multiplication with a mechanical adding/subtracting calculator based on gears, with mutilated gears for carry. Blaise Pascal started to develop a mechanical calculator – the Pascaline.
How much was the first calculator?
Jack S. Kilby, an engineer at Texas Instruments, had invented the integrated circuit (IC) at TI in 1958. A year earlier a Japanese firm had introduced the first all-transistor desktop calculator; it weighed 55 pounds and cost $2500.
Today, calculators are everywhere. Many kids probably take them for granted. After all, any smartphone will have a calculator application right there on the home screen. You can also go to any discount store and pick up a basic solar-powered calculator for a dollar or two. If you have a computer, you have all the calculating power you need at your fingertips.
Although calculators are very common today, they weren’t always cheap and easily accessible. In fact, they didn’t really come around until the dawn of the computer age. Before that time, you had to rely upon pencil and paper or, perhaps, an older counting instrument, such as an abacus.
So, How a Calculator Calculates?
As you learned on previous pages, most calculators depend on integrated circuits, commonly known as chips. These circuits use transistors to add and subtract, as well as to perform computations on logarithms in order to accomplish multiplication, division and more complicated operations such as using exponents and finding square roots. Basically, the more transistors an integrated circuit has, the more advanced its functions may be. Most standard pocket calculators have identical, or very similar, integrated circuitry.
What’s inside a calculator?
If you’d taken apart a 19th-century calculator, you’d have found hundreds of parts inside: lots of precision gears, axles, rods, and levers, greased to high heaven, and clicking and whirring away every time you keyed in a number. But take apart a modern electronic calculator (I just can’t resist undoing a screw when I see one!) and you might be disappointed at how little you find. I don’t recommend you do this with your brand-new school calculator if you want to stay on speaking terms with your parents, so I’ve saved you the bother. Here’s what you’ll find inside:
Input: Keyboard: About 40 tiny plastic keys with a rubber membrane underneath and a touch-sensitive circuit underneath that.
Processor: A microchip that does all the hard work. This does the same job as all the hundreds of gears in an early calculator.
Output: A liquid crystal display (LCD) for showing you the numbers you type in and the results of your calculations.
Power source: A long-life battery (mine has a thin lithium “button” cell that lasts several years). Some calculators also have a solar cell to provide free power in the daylight.
And that’s about it!
What happens when you press a key?
Press down on one of the number keys on your calculator and a series of things will happen in quick succession:
As you press on the hard plastic, you compress the rubber membrane underneath it. This is a kind of a miniature trampoline that has a small rubber button positioned directly underneath each key and a hollow space underneath that. When you press a key, you squash flat the rubber button on the membrane directly underneath it.
The rubber button pushes down making an electrical contact between two layers in the keyboard sensor underneath and the keyboard circuit detects this.
The processor chip figures out which key you have pressed.
A circuit in the processor chip activates the appropriate segments on the display corresponding to the number you’ve pressed.
If you press more numbers, the processor chip will show them up on the display as well—and it will keep doing this until you press one of the operations keys (such as +, −, ×, ÷) to make it do something different. Suppose you press the + key. The calculator will store the number you just entered in a small memory called a register.
Then it will wipe the display and wait for you to enter another number. As you enter this second number, the processor chip will display it digit-by-digit as before and store it in another register. Finally, when you hit the = key, the calculator will add the contents of the two registers together and display the result.
There’s a little more to it than that—and I’ll go into a few more details down below.
How does the display work?
You’re probably used to the idea that your computer screen makes letters and numbers using a tiny grid of dots called pixels.
Early computers used just a few pixels and looked very dotty and grainy, but a modern LCD screen uses millions of pixels and is almost as clear and sharp as a printed book.
Calculators, however, remain stuck in the dark ages—or the early 1970s, to be precise. Look closely at the digits on a calculator and you’ll see each one is made from a different pattern of seven bars or segments.
The processor chip knows it can display any of the numbers 0-9 by activating a different combination of these seven segments. It can’t easily display letters, though some scientific calculators (more advanced electronic calculators with lots of built into mathematical and scientific formulae) do have a go.
In this example you will learn to create a simple calculator that can add, subtract, multiply or divide depending upon the input from the user.
To understand this example, you should have the knowledge of the following Python programming topics:
Python Function Arguments
Python User-defined Functions
Simple Calculator by Using Functions
# Program make a simple calculator
# This function adds two numbers
def add(x, y):
return x + y
# This function subtracts two numbers
def subtract(x, y):
return x - y
# This function multiplies two numbers
def multiply(x, y):
return x * y
# This function divides two numbers
def divide(x, y):
return x / y
# Take input from the user
choice = input("Enter choice(1/2/3/4): ")
# Check if choice is one of the four options
if choice in ('1', '2', '3', '4'):
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))
elif choice == '2':
print(num1, "-", num2, "=", subtract(num1, num2))
elif choice == '3':
print(num1, "*", num2, "=", multiply(num1, num2))
elif choice == '4':
print(num1, "/", num2, "=", divide(num1, num2))
Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15.0 * 14.0 = 210.0
In this program, we ask the user to choose an operation. Options 1, 2, 3, and 4 are valid. If any other input is given, Invalid Input is displayed and the loop continues until a valid option is selected.
Two numbers are taken and an if...elif...else branching is used to execute a particular section. User-defined functions add(), subtract(), multiply() and divide() evaluate respective operations and display the output.