Chapter 6 Grade 12
Chapter 6 Grade 12
Chapter 6 Grade 12
Fundamentals of programming
A computer is an electronic device that can be instructed to carryout sequences of arithmetic or
logical operations automatically via computer programming.
Modern computers have the ability to follow generalized sets of operations, called
programs. These programs enable computers to perform an extremely wide range of tasks.
Computers are used as control systems for a wide variety of industrial and consumer devices like
microwave ovens, remote controls, industrial robots, computer-aided design, personal computers,
and mobile devices.
Program: A set of directions (instructions) telling a computer exactly what to do.
programmer or developer: A person who write/develop program follow series of steps and
cycles starting from collecting user specifications until the software is ready for delivery
Algorithm
A sequence of language independent steps which may be followed to solve a problem.
1. Sequence
2. Selection 3. Iteration
1.sequential logic
Example:
Design an algorithm that adds two numbers and display the result
Solution
In the above problem the instructions are executed in the order they are from top to bottom
Example:
Solution
1. Start.
4. Display area.
5. Stop
2. Selection logic
Selecting the proper path out of two or more alternative paths in the program logic
Example 1
Design an algorithm which calculates a quadratic equation
Ax2 + BX + C = 0
Else continue.
r1 = ( -B + sqrt(B2- 4AC)/(2A))
3. Iteration
Used when one or more instructions may be executed several times depending on some
condition.
Example. Design an algorithm that adds 100 numbers and display the result
Step1 : Set i =1
Set sum=0
Increment i
else continue
Flow chart
Programmers use different kinds of tools or aids which help them in developing programs and
algorithms faster and better.
Flow charts
-Boxes are connected by solid lines having arrow marks to indicate the flow of operation.
-Since a flowchart shows the flow of operations in pictorial form, any error in the logic of the
procedure can be detected easily.
Flowchart Symbols
Example
Introduction to phyton
Python is a versatile programming language that is widely used in data science, web
development, and artificial intelligence. At Data Science Cookie, we offer an Introduction to
Python program designed to equip participants with the basic skills needed to start coding in
Python.
Python is a multi-purpose programming language (due to its many extensions), examples are
scientific computing and calculations, simulations, web development.
Python Editors
An Editor is a program where you create your code (and where you can run and test it). Most
Editors have also features for Debugging. For simple Python programs you can use the IDLE
Editor, but for more advanced programs a better editor is recommended.
Examples of Python Editors:
• Python IDLE
• Spyder
• Visual Studio
• PyCharm
• Jupyter Notebook
These editors are shortly described below and in more detail later in this textbook. Which editor
you should use depends on your background, what kind of code editors you have used
previously, your programming skills, what you are going to develop in Python, etc.