Sooner or later, it was supposed to happen. Check out a new task from Muffin.
Third task: “Write a program for calculating the caloric value of my breakfast. I eat milk for breakfast. I want to enter the amount I ate and see its caloric value.”
Why didn’t he put it this way right from the start?! Let’s forgive Muffin. He is a nocturnal, solitary predator, fast and agile, but not as savvy as his colleagues, raccoons. So he will be making tasks more difficult slowly.
It won’t be easy to complete this task from the first attempt, so we will do it step by step.
We have already written code for a program that worked with known data. This data was defined right in the code of the program.
However, you will be mostly working with data unknown during the start of the program. For example, you will be capturing the user’s input and process it.
To begin with, let’s learn to receive data from the user. That is, from the boss a.k.a Muffin. To do it, let’s page him using a special command:
keks.ask('question for the boss');
You will also learn how to create your own commands in programs, give them names and access them for operations. We’ll see how it’s done in future courses. Try collecting data from Muffin. Don’t forget that a question is a string, and you need to enclose it in quote marks: