Hey there! Welcome to Day 10 of a 100 Days of Code
and today we're gonna learn about functions with
outputs. Previously
we've already seen the other two flavors of functions; a plain function and
also functions with inputs. But in today's lessons,
we're going to be using the skills that we've learned
and we're going to be extending our knowledge of functions to build a
calculator app. I think at some point in every program has lives
they will have built a calculator app.
So if that hasn't already happened to you, then today is your lucky day,
because that's exactly what we're going to be making.
So it's a simple text base calculator,
and we can start off by writing a number and then picking one of the operations:
plus, minus, multiply or divide. So I'm going to divide this by two,
and then it shows us the full calculation, 5 / 2 = 2.5.
And now we can continue calculating with the answer from the previous step,
or we can type 'n' to start a new calculation. Let me type a 'y'
and maybe I'll do 2.5 + 6
and now I get 8.5. By the end of the lessons today,
you'll have understood how functions really work,
how you can use them to reduce redundant code and how you can provide inputs to
functions as well as providing outputs. Once you're ready, head over to the next
lesson and let's get started.