--Originally published at Welcome to the Heaven
Hi folks!! Today we will learn a lot of important topics in Python 3, like “Basic Output and Input”, “functions”, “use of if, elif and else” and how to make a “Loop” with while in a polite calculator.
The first step is create a function and the way to create a function is write def, next to the name of the function with parentheses and two points. Inside the parentheses we can write the variables that you’ll use in the function. #def is a block keyword to say to the computer that we’ll create a function an what will be its name
Example:
After that we begin to write all the code of the function, in the case of the calculator we star with a output and input, to make the user feel comfortable.
In this case our Output is print(“Welcome”) that will say to the user the word <Welcome> and in the next line the Input will put <Do you want to use my Calculator? > where you can write yes or no
Okay, know we use a Loop with while, because we want that our calculator will never end if we don’t want so we write:
That’s means the program doesn’t have end if we write yes. In the final to close the loop we write. #<okay Bye> is only to be polite
When we have our loop, we can write the operations that our calculator will use. This prototype only work with addition, subtraction, multiplication and division, if you want you can make it work with more functions, like sin or cos…
The way to do all the operations is with the use of if, elif, input and output. Is pretty easy to do with this conditionals because the operations don’t need to import a
Continue reading "One shot, a lot of points." →