Page 218 - Ai_V1.0_Class9
P. 218

UNIT-5



                                                                     INTRODUCTION TO


                                                                                  PYTHON










              A computer is just a machine that gives the result based on the instructions or inputs given to it. In order
              to get a problem solved by a computer, we need to give step-by-step instructions to the computer.  These
              step-by-step instructions written in any programming language to do a specific task is known as a program. A
              program is written in any programming language which the computer can understand and execute. Algorithms
              and flowchart are powerful tools for learning programming.
              In this chapter, we are going to learn about basic concepts of programming including problem-solving, control
              structure, algorithm, and flowchart.


                       Steps Involved in Computer Problem Solving

              Before we write a program, we need to learn the basic objective of it. Why do we need a program and what
              purpose does it solve? To solve this problem of writing a program, we follow some steps as given below:
              1.  Understanding the problem: This is a crucial step where we need to understand the main objective of the
                 problem. In this step, we should clearly define the problem, gather all necessary requirements, understand
                 constraints, and clarify goals. These actions are essential to moving in the right direction and finding an
                 effective solution.

              2.  Analysing the problem: Break down the problem into smaller parts, identify inputs and outputs, and explore
                 existing solutions. Consider edge cases and unusual scenarios. This comprehensive analysis sets a detailed
                 plan for tackling the problem.
              3.  Developing the solution: Design a detailed algorithm and choose appropriate tools and technologies. It is
                 always recommended to first write an algorithm and draw a flowchart for solving a problem and then only
                 write the program. This translates analysis into a practical, actionable plan.
              4.  Coding and implementation: This is the last step where every instruction of an algorithm is converted into
                 a computer understandable instruction by using the syntax and semantic of a specific computer language.

                       Control Structures

              Control structures are a set of instructions that control the flow of instructions in a program. It is a programming
              tool that determines the order of execution of the statements in any programming language. There are three
              different types of control structures: sequential flow, selection flow, and repetition flow.
              Let us learn about these in detail.


              Sequential Flow
              In sequential flow, the statements are placed one after the other and the flow of execution occurs starting from line
              1, line 2 and so on with a top-down approach. It is the default flow followed in any programming language. For
              example, the steps for calculating the percentage of any student by taking as an input marks of English, Science,

                    216     Artificial Intelligence Play (Ver 1.0)-IX
   213   214   215   216   217   218   219   220   221   222   223