computer_basics:structured_programming_concepts
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
computer_basics:structured_programming_concepts [2018/07/24 00:51] – created mithat | computer_basics:structured_programming_concepts [2018/07/24 22:13] (current) – [Practical reasons] mithat | ||
---|---|---|---|
Line 8: | Line 8: | ||
===== Topics ===== | ===== Topics ===== | ||
- | * What is it? | + | |
- | * Why is it important? | + | * Why is it important? |
- | * Core concepts | + | * Core concepts |
===== What is it? ===== | ===== What is it? ===== | ||
- | * A way of thinking about how to create computer programs: a **paradigm**. | + | |
- | * Developed in the late 1950s to help create manageable computer programs. | + | * Developed in the 1950s to help create manageable computer programs. |
===== Why is it important? ===== | ===== Why is it important? ===== | ||
- | * Theoretical reasons | + | |
- | * Practical reasons | + | * Practical reasons |
===== Theoretical reasons ===== | ===== Theoretical reasons ===== | ||
- | * Proven that it's is all you need to write any " | + | |
- | * Dominates theoretical thinking. | + | * Dominates theoretical thinking. |
===== Practical reasons ===== | ===== Practical reasons ===== | ||
- | * Many popular | + | |
- | * Influences languages built around other paradigms. | + | * Influences languages built around other paradigms. |
- | * Thinking " | + | * Thinking " |
- | * Professionals often use structured programming concepts to specify ways of solving problems. | + | * Professionals often use structured programming concepts to specify ways of solving problems. |
===== Core concepts ===== | ===== Core concepts ===== | ||
- | * Control flow | + | |
- | * Block structure | + | * Block structure |
- | * Subroutines | + | * Subroutines |
===== Control flow ===== | ===== Control flow ===== | ||
- | * **control flow**: the order in which the things happen, the way a program " | + | |
- | * Three kinds of control structures | + | * Three kinds of control structures |
* **sequence**: | * **sequence**: | ||
- | * **selection**: | + | * **selection**: |
- | * **repetition**: | + | * **repetition**: |
===== Scenario ===== | ===== Scenario ===== | ||
- | * I need to leave my house for a couple days. | + | |
- | * My friend has agreed to look after my cat Zoë. | + | * My friend has agreed to look after my cat Ash. |
- | * They need detailed instructions. | + | * They need detailed instructions. |
===== First try ===== | ===== First try ===== | ||
- | //Zoë gets a cup of food every day. | + | //Ash gets a cup of food every day.\\ |
- | Her water needs to be filled if it's running low. | + | Her water needs to be filled if it's running low.\\ |
She also needs to play fetch with her favorite toy.// | She also needs to play fetch with her favorite toy.// | ||
===== Sequence ===== | ===== Sequence ===== | ||
- | "Zoë gets a cup of food every day." | + | "Ash gets a cup of food every day." |
- | | + | |
- | scoop out one cup of food | + | scoop out one cup of food |
- | put the scoop of food into her food dish | + | put the scoop of food into her food dish |
- | reseal the bag of catfood | + | reseal the bag of catfood |
===== Selection ===== | ===== Selection ===== | ||
"Her water needs to be filled if it's running low." | "Her water needs to be filled if it's running low." | ||
- | | + | |
- | fill a glass of water from the filtered water pitcher on the counter | + | fill a glass of water from the filtered water pitcher on the counter |
- | pour the glass of water into the water dish | + | pour the glass of water into the water dish |
===== Repetition ===== | ===== Repetition ===== | ||
"She also needs to play fetch with her favorite toy." | "She also needs to play fetch with her favorite toy." | ||
- | | + | |
- | while Zoë brings it back | + | while Ash brings it back |
- | pat her on the head | + | pat her on the head |
- | toss Zoë's favorite toy | + | toss Ash's favorite toy |
===== Code Examples ===== | ===== Code Examples ===== | ||
Line 79: | Line 79: | ||
===== Sequence ===== | ===== Sequence ===== | ||
- | ```python | + | < |
a = 5 | a = 5 | ||
b = 4 | b = 4 | ||
c = a * b | c = a * b | ||
print(" | print(" | ||
- | ``` | + | </ |
===== Selection ===== | ===== Selection ===== | ||
- | ```python | + | < |
if a > 60: | if a > 60: | ||
print(" | print(" | ||
print(" | print(" | ||
- | ``` | + | </ |
===== Repetition ===== | ===== Repetition ===== | ||
- | ```python | + | < |
n = 1 | n = 1 | ||
while n < 10: | while n < 10: | ||
Line 102: | Line 102: | ||
k = n + 1 | k = n + 1 | ||
n = k | n = k | ||
- | ``` | + | </ |
+ | < | ||
+ | < | ||
+ | for(var i=0, | ||
+ | </ | ||
+ | </ |
computer_basics/structured_programming_concepts.1532393489.txt.gz · Last modified: 2018/07/24 00:51 by mithat