Before moving forward, Let's learn how to install Python software in your System which is very important for the further understanding of these topics.
Imagine, you are a regular customer of Uncle Sam’s Pizza restaurant, can you help Uncle Sam prepare the menu and take a printout of it? Which application will you use for that? You will type the menu using MS word and then take a printout of it. right?
So, you know that we can use MS Word to create documents.
Similarly, if you want to write a python program, you need an IDE (Integrated development environment). This IDE helps you to write a python program and then run it so that you can see the result/output of the program.
Steps to install python/IDE in your local system. (Windows /MAC )
Note: Prerequisite for installing python in Windows- Windows 8 or above.
1. Click on download python as per your OS. Mac users may download the Mac version. Windows users download depending on 32-bit or 64-bit.
2. Run the downloaded .exe file.
3. Select both checkboxes and then click on install now.
4. Allow the installer to make changes to a computer.
5. Wait till the installation completes.
6. Once installation is complete, you will get a screen like this.
The name of the IDE we are using is IDLE (Integrated Development and Learning Environment.)
Now let's understand how to write a program in python.
1. Go to run-> type IDLE->click on it Or Goto the folder where Python is installed->open IDLE.
2. To write a new code, Click on File->New File.
3. You can enter the code in the white area. To run code written,
1. Click on Run->Run Module
2. The python shell will open showing the output.
we have successfully installed python in your system.
Sequence:
Let's understand the sequence with a basic example.
Do you know how to make a pizza? Have you ever tried making your own homemade pizza? Let's make one now.
1. Prepare the dough and roll it into a circle.
2. Put on the pizza sauce, cheese, and toppings.
3. Put the pizza in the oven.
4. Bake until the pizza is crispy and golden brown.
Now tell me, is it possible to skip steps 2 & 3 and arrive at step 4 from step 1 directly. Is it possible to do step 2 before step 1? No right?
When things are arranged in the correct sequence; it is not possible to skip a step or alter the sequence. It has to be followed as it is. Correct ordering is important because if we don't follow the correct order we will not get the correct result.
The same is the case when you are giving instructions to the computer. Each step of the sequence has to be followed as it is.
Algorithm:
An algorithm is the set of instructions given in the correct order(sequence) to complete a task. It can be in English or any other language understandable by the user.
Do you know, just now you came up with the algorithm to make pizza. But do you think, the computer will understand if you give these instructions in English? Correct!! So if you want to give instructions to a computer, it has to be in some programming language understandable by the computer.
Program:
A program is a set of instructions given to a computer, in some programming language. The algorithm serves as a blueprint to write a program. Alright, now let's watch something to understand this in a better way!
What happens in the video? The dad is not able to make the sandwich following the kid’s instructions, isn’t it?
And why is that?
● the sequence of the algorithm wasn't correct and that is the reason that the final result was not what the dad wanted.
● the algorithm has to be very specific if you need the desired result. So did you enjoy it
Now let’s move on and help Uncle Sam in the restaurant.
Uncle Sam wants to help the customers in all possible ways. So, can you tell me the algorithm to place the order in the restaurant, so that Uncle Sam can display it as a tip?
● Go to the counter.
● Tell the choice of pizza and quantity required.
● The salesman places the order and generates the bill.
● Make the payment.
● Get balance.
● Wait for your order to be ready Now suppose the restaurant wants the customer to enter their phone number, to maintain a record of the client. Develop an algorithm to validate if the phone number entered is correct or not.
● Check the length of the phone number entered. It has to be 10. If not 10, the number is not valid
● Check all the characters in the phone number. All of them should be numbers else it won’t be valid. Note: Looping through the number is not given since the student is not introduced to that concept.
Let’s try to write a program now for Uncle Sam who wants to display pizza-making steps in the kitchen.
(Welcome to Pizza Hub Today's Special
----------------------------------------
1. Large Pizza Rs. 120
2. Medium Pizza Rs. 80
3. Small Pizza Rs. 60
4. Toppings extra Rs. 10
5. Extra cheese Rs. 15
----------------------------------------
Place the order on the counter and wait 10 mins for your order Thanks for giving us a chance to serve you.
Comments
Post a Comment