6.82M
Категория: ПедагогикаПедагогика

A quick information guide

1.

A quick information guide
Algorithms 1
A preview of algorithms

2.

Agenda
Key topics discussed
in this presentation
What is algorithm
Building algorithms using diagrams
What is condition
Comparison operators
Solving problems using diagrams

3.

Algorithm
• Writing a STEP BY STEP method to solve the problem is called the
algorithm.
• Algorithm is a list of instructions(commands) you should do to solve a
problem.
• The order of instructions is very important!

4.

Real life example
• Fill the pot(or pan) with water
• Boil the water inside the pot
• Put eggs inside the pot
• Wait for 7-10 minutes
• Remove the eggs from the pot

5.

The order is important
• Put eggs inside the pot
• Remove the eggs from the pot
• Wait for 7-10 minutes
• Fill the pot(or pan) with water
• Boil the water inside the pot

6.

Sum of 2 numbers
• You are given 2 numbers (inputs from keyboard).
• You need to find the sum of these two numbers and print it out.
Solution
• Read the first value and save it as A
• Read the second value and save it as B
• Add the value of A to the value of B
and save the result as S
• Print the value of S

7.

Shape
The meaning
Start or End of an algorithm
Input or Output operations (Read and Print)
One operation of an algorithm
Flow of algorithms (order)
Decision in algorithm (conditions)

8.

Sum of 2 numbers
• Read the first value and save it as A
• Read the second value and save it as B
• Add the value of A to the value of B
and save the result as S
• Print the value of S
To create diagrams use website:
https://app.diagrams.net/

9.

Average of 2 numbers
• You are given 2 numbers (inputs from keyboard).
• You need to find the average of these two numbers and print it out.
Solution (try to build it using flowcharts)
• Read first value and save it as A
• Read second value and save it as B
• Add the value of A to the value of B and save the result as S
• Divide the value of S by 2 and save the result as R
• Print the value of R

10.

Average of 2 numbers
• Read first value and save it as A
• Read second value and save it as B
• Add the value of A to the value of B and save the
result as S
• Divide the value of S by 2 and save the result as R
• Print the value of R

11.

Perimeter and Area of a square
• You are given one number(a side length of a square). This number is
entered by a user.
• You need to find the Perimeter and Area of this square. Print the results.
Solution (try to build it using flowcharts)
• Read the value and save it as A
• Multiply A by 4 and save the result as P
• Multiply A by A and save the result as S
• Print the value of P
• Print the value of S

12.

Perimeter and Area of a square
• Read the value and save it as A
• Multiply A by 4 and save the result as P
• Multiply A by A and save the result as S
• Print the value of P
• Print the value of S

13.

Conditions
• Programming languages allow us to create programs that can make
decisions based on certain conditions.
• IF the traffic light is green I will continue driving, IF NOT I will stop and
wait. So I will make decision based on condition.

14.

Conditions
• Condition is like a question, you can answer like "Yes" or "No".
• But in programming instead of "Yes" or "No" we say "True" or "False".
• So any condition as a result gives either True or False.

15.

Comparison operators
Is the value of X is equal to the value of Y ?
X == Y
Is the value of X is NOT equal to the value of Y ?
X != Y
Is the value of X is greater than the value of Y ?
X>Y
Is the value of X is less than the value of Y ?
X<Y
Is the value of X is greater OR equal to the value of Y ?
X >= Y
Is the value of X is less OR equal to the value of Y ?
X <= Y

16.

If numbers are equal
• You are given two numbers(inputs from keyboard).
• You need to find if these numbers are equal or not. Print one of the
⚬ Input: 6 8
⚬ Output: Not equal
⚬ Input: 6 6
⚬ Output: Equal

17.

If numbers are equal
• You are given two numbers(inputs from
keyboard).
• You need to find if these numbers are
equal or not. Print one of the messages:

18.

Minimum of 2 numbers
• You are given two numbers.
• You need to find minimum value and print it.
⚬ Input: 6 8
⚬ Output: 6
⚬ Input: 9 8
⚬ Output: 8

19.

Minimum of 2 numbers
• You are given two numbers.
• You need to find minimum value and print it.

20.

Thank you
English     Русский Правила