<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://staging.moocwiki.org/index.php?action=history&amp;feed=atom&amp;title=English%3AConditional_Logic_and_Loops</id>
	<title>English:Conditional Logic and Loops - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://staging.moocwiki.org/index.php?action=history&amp;feed=atom&amp;title=English%3AConditional_Logic_and_Loops"/>
	<link rel="alternate" type="text/html" href="https://staging.moocwiki.org/index.php?title=English:Conditional_Logic_and_Loops&amp;action=history"/>
	<updated>2026-08-28T13:24:35Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in MOOCsWiki Staging</subtitle>
	<generator>MediaWiki 1.45.4</generator>
	<entry>
		<id>https://staging.moocwiki.org/index.php?title=English:Conditional_Logic_and_Loops&amp;diff=47139&amp;oldid=prev</id>
		<title>Glanz: aiMOOC über GPT aiMOOC Action erstellt</title>
		<link rel="alternate" type="text/html" href="https://staging.moocwiki.org/index.php?title=English:Conditional_Logic_and_Loops&amp;diff=47139&amp;oldid=prev"/>
		<updated>2026-08-27T12:17:17Z</updated>

		<summary type="html">&lt;p&gt;aiMOOC über GPT aiMOOC Action erstellt&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{T}}&lt;br /&gt;
[[Category:English]]&lt;br /&gt;
[[Category:Conditional Logic and Loops]]&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Conditional Logic and Loops&amp;#039;&amp;#039;&amp;#039; is a Grades 9–10 course about two core ideas in [[English:Computer programming|programming]]: making decisions and repeating actions. Together, these ideas control the order in which instructions run. This order is called [[English:Control flow|control flow]].&lt;br /&gt;
&lt;br /&gt;
You use conditional logic when a program must choose between actions. You use loops when a program must repeat an action, process several items, or continue until a condition changes. These ideas appear in games, apps, robotics, websites, data analysis, simulations, and many everyday algorithms.&lt;br /&gt;
&lt;br /&gt;
A [[English:Flowchart|flowchart]] can make control flow visible. Arrows show the path of execution, while decision shapes show where the path can change.&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart en.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
By the end of this aiMOOC, you should be able to read, trace, design, explain, and debug programs that use conditions and loops. The examples use clear Python-like syntax, but the main ideas apply to many programming languages.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Learning Goals =&lt;br /&gt;
&lt;br /&gt;
After working through the course, you can:&lt;br /&gt;
# [[English:Control flow|Control flow]]: Explain how a program moves through a sequence of instructions, decisions, and repeated blocks.&lt;br /&gt;
# [[English:Conditional (computer programming)|Conditional statements]]: Use conditions to choose between alternative actions.&lt;br /&gt;
# [[English:Boolean algebra|Boolean logic]]: Combine comparisons with AND, OR, and NOT.&lt;br /&gt;
# [[English:Loop (computing)|Loops]]: Choose and use for loops and while loops for suitable problems.&lt;br /&gt;
# [[English:Debugging|Debugging]]: Trace variable values and locate common logic errors such as off-by-one mistakes and infinite loops.&lt;br /&gt;
# [[English:Algorithm|Algorithm]]: Design a simple algorithm that combines decisions and repetition to solve a real problem.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Control Flow: Decisions and Repetition =&lt;br /&gt;
&lt;br /&gt;
A program normally executes instructions in sequence, one after another. Conditional statements and loops change that simple sequence. A conditional statement creates &amp;#039;&amp;#039;&amp;#039;branches&amp;#039;&amp;#039;&amp;#039;: only a selected path runs. A loop creates &amp;#039;&amp;#039;&amp;#039;repetition&amp;#039;&amp;#039;&amp;#039;: a block can run more than once.&lt;br /&gt;
&lt;br /&gt;
The diamond-shaped symbol below represents a decision in a flowchart. A decision asks a question whose result determines which path the algorithm follows.&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart Decision.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
A useful way to think about control flow is to ask two questions: &amp;#039;&amp;#039;&amp;#039;What decides the next step?&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;What makes repetition stop?&amp;#039;&amp;#039;&amp;#039; If you can answer both questions, you can often predict the behavior of the program.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Conditional Logic ==&lt;br /&gt;
&lt;br /&gt;
A [[English:Conditional (computer programming)|conditional statement]] checks a condition. The condition evaluates to either true or false. If it is true, one block can run; if it is false, another block may run.&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart-If Then Else.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
Here is a simple Python-style example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
temperature = 31&lt;br /&gt;
&lt;br /&gt;
if temperature &amp;gt; 30:&lt;br /&gt;
    print(&amp;quot;Drink water&amp;quot;)&lt;br /&gt;
else:&lt;br /&gt;
    print(&amp;quot;Normal plan&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The expression &amp;lt;code&amp;gt;temperature &amp;gt; 30&amp;lt;/code&amp;gt; is the condition. Because 31 is greater than 30, the first branch runs.&lt;br /&gt;
&lt;br /&gt;
An &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statement can stand alone when an action is needed only in one situation. An &amp;lt;code&amp;gt;if/else&amp;lt;/code&amp;gt; structure is useful when exactly one of two alternatives should run. An &amp;lt;code&amp;gt;if/elif/else&amp;lt;/code&amp;gt; chain can test several cases. In such a chain, conditions are tested in order, and the first true branch is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
score = 82&lt;br /&gt;
&lt;br /&gt;
if score &amp;gt;= 90:&lt;br /&gt;
    print(&amp;quot;Excellent&amp;quot;)&lt;br /&gt;
elif score &amp;gt;= 70:&lt;br /&gt;
    print(&amp;quot;On target&amp;quot;)&lt;br /&gt;
else:&lt;br /&gt;
    print(&amp;quot;Keep practising&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The order matters. If a broad condition appears before a more specific condition, the broad condition may capture cases that should have reached the later branch.&lt;br /&gt;
&lt;br /&gt;
For a deeper explanation of conditionals in Python, watch this CS50 lesson:&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|https://www.youtube.com/watch?v=_b6NgY_pMdw|500|center}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Boolean Expressions and Operators ==&lt;br /&gt;
&lt;br /&gt;
A [[English:Boolean data type|Boolean value]] is either true or false. Conditions often use comparison operators such as &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;!=&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;amp;lt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;amp;lt;=&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;&amp;amp;gt;=&amp;lt;/code&amp;gt;. Many languages also provide Boolean operators that combine or change conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is true only when both required conditions are true. &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is true when at least one of its conditions is true. &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; reverses a Boolean value.&lt;br /&gt;
&lt;br /&gt;
[[File:Boolean logic.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
Suppose a school event allows entry when a student has a ticket and has arrived before the doors close:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
has_ticket = True&lt;br /&gt;
doors_open = True&lt;br /&gt;
&lt;br /&gt;
if has_ticket and doors_open:&lt;br /&gt;
    print(&amp;quot;Enter the event&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compound conditions should be written so that another reader can understand the rule. When a condition becomes long, give parts of it meaningful variable names or split the logic into smaller steps.&lt;br /&gt;
&lt;br /&gt;
A common programming mistake is confusing assignment with comparison. In Python and many other languages, &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt; assigns a value, while &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt; tests whether two values are equal. The exact symbols vary by language, so always check the rules of the language you are using.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Loops =&lt;br /&gt;
&lt;br /&gt;
A [[English:Loop (computing)|loop]] repeats a block of instructions. Each pass through the loop is an &amp;#039;&amp;#039;&amp;#039;iteration&amp;#039;&amp;#039;&amp;#039;. Loops are useful when you want to process a collection, repeat an action a fixed number of times, or continue until a condition changes.&lt;br /&gt;
&lt;br /&gt;
Before writing a loop, identify three things: the starting state, the condition or collection that controls repetition, and the change that moves the loop toward completion. This habit prevents many logic errors.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== For Loops ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;for loop&amp;#039;&amp;#039;&amp;#039; is often a good choice when the number of repetitions is known or when you are processing each item in a collection.&lt;br /&gt;
&lt;br /&gt;
[[File:For loop.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for step in range(5):&lt;br /&gt;
    print(&amp;quot;Practice step&amp;quot;, step)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This loop runs five times. In Python, &amp;lt;code&amp;gt;range(5)&amp;lt;/code&amp;gt; produces the values 0, 1, 2, 3, and 4. The loop variable changes automatically on each iteration.&lt;br /&gt;
&lt;br /&gt;
A for loop is also useful for processing a list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
names = [&amp;quot;Amina&amp;quot;, &amp;quot;Leo&amp;quot;, &amp;quot;Maya&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
for name in names:&lt;br /&gt;
    print(&amp;quot;Hello&amp;quot;, name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The body runs once for each name. This pattern is clearer than manually repeating the same print instruction.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== While Loops ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;while loop&amp;#039;&amp;#039;&amp;#039; repeats as long as its condition remains true. It is especially useful when you do not know in advance exactly how many iterations will be needed.&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart-While.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
attempts = 0&lt;br /&gt;
&lt;br /&gt;
while attempts &amp;lt; 3:&lt;br /&gt;
    print(&amp;quot;Try again&amp;quot;)&lt;br /&gt;
    attempts = attempts + 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;attempts&amp;lt;/code&amp;gt; starts at 0 and increases on each iteration. When it reaches 3, the condition becomes false and the loop stops.&lt;br /&gt;
&lt;br /&gt;
A while loop needs careful design. If the variables in its condition never change in a way that can make the condition false, the loop may continue forever. This is called an &amp;#039;&amp;#039;&amp;#039;infinite loop&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;sentinel value&amp;#039;&amp;#039;&amp;#039; is a special input that tells a loop to stop. For example, a data-entry program might keep accepting words until the user enters &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;. Sentinels are useful when the number of inputs is not known in advance.&lt;br /&gt;
&lt;br /&gt;
For a full lesson on loops, including for loops, while loops, input validation, and nested loops, watch this CS50 lesson:&lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|https://www.youtube.com/watch?v=-7xg8pGcP6w|500|center}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Nested Loops ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;nested loop&amp;#039;&amp;#039;&amp;#039; is a loop inside another loop. Nested loops are useful for grids, tables, pixel patterns, board games, and combinations of items.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for row in range(3):&lt;br /&gt;
    for column in range(4):&lt;br /&gt;
        print(row, column)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The outer loop runs three times. For each outer iteration, the inner loop runs four times. Therefore, the print instruction runs 12 times.&lt;br /&gt;
&lt;br /&gt;
Nested loops can grow expensive quickly because the inner work is repeated for every outer iteration. At this level, the key skill is to trace the two loop variables carefully and ask how many times the innermost instruction will run.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Combining Conditionals and Loops =&lt;br /&gt;
&lt;br /&gt;
Powerful algorithms often place a conditional inside a loop. The loop handles repetition, while the conditional decides what to do during each iteration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scores = [72, 91, 64, 88]&lt;br /&gt;
&lt;br /&gt;
for score in scores:&lt;br /&gt;
    if score &amp;gt;= 70:&lt;br /&gt;
        print(&amp;quot;Target reached&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;More practice needed&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This program examines every score and makes a decision for each item. The same structure can classify sensor readings, check quiz answers, filter data, control a game character, or validate a series of inputs.&lt;br /&gt;
&lt;br /&gt;
You can also place a loop inside a conditional. For example, a program might repeat a training sequence only if the user selects practice mode. The most important design rule is that each condition and loop should have a clear purpose.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Counters, Accumulators, and State =&lt;br /&gt;
&lt;br /&gt;
Programs often need to remember what has happened so far. A &amp;#039;&amp;#039;&amp;#039;counter&amp;#039;&amp;#039;&amp;#039; records how many times something has occurred. An &amp;#039;&amp;#039;&amp;#039;accumulator&amp;#039;&amp;#039;&amp;#039; builds a running total. More generally, the current values of variables form the program&amp;#039;s &amp;#039;&amp;#039;&amp;#039;state&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
total = 0&lt;br /&gt;
&lt;br /&gt;
for value in [4, 7, 3]:&lt;br /&gt;
    total = total + value&lt;br /&gt;
&lt;br /&gt;
print(total)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing the state means recording how values change after each important line or iteration. This is one of the best ways to understand unfamiliar code.&lt;br /&gt;
&lt;br /&gt;
A loop that counts from 0 may create an &amp;#039;&amp;#039;&amp;#039;off-by-one error&amp;#039;&amp;#039;&amp;#039; if you accidentally run one iteration too many or too few. Carefully checking the first value, the final allowed value, and the stopping condition helps prevent this error.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Tracing and Debugging =&lt;br /&gt;
&lt;br /&gt;
[[English:Debugging|Debugging]] is the process of finding and fixing errors. A syntax error breaks the language rules and is often reported by the programming environment. A logic error allows the program to run but produces an incorrect result. Conditional and loop bugs are often logic errors.&lt;br /&gt;
&lt;br /&gt;
Use a trace table to follow values step by step:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Iteration&lt;br /&gt;
! counter before update&lt;br /&gt;
! condition&lt;br /&gt;
! action&lt;br /&gt;
|-&lt;br /&gt;
| first&lt;br /&gt;
| 0&lt;br /&gt;
| true&lt;br /&gt;
| print and add one&lt;br /&gt;
|-&lt;br /&gt;
| second&lt;br /&gt;
| 1&lt;br /&gt;
| true&lt;br /&gt;
| print and add one&lt;br /&gt;
|-&lt;br /&gt;
| third&lt;br /&gt;
| 2&lt;br /&gt;
| true&lt;br /&gt;
| print and add one&lt;br /&gt;
|-&lt;br /&gt;
| after loop&lt;br /&gt;
| 3&lt;br /&gt;
| false&lt;br /&gt;
| stop&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When debugging, test boundary cases. If a condition uses a threshold, test values just below, exactly at, and just above the threshold. If a loop processes a list, test an empty list, a one-item list, and a longer list when your programming environment allows it.&lt;br /&gt;
&lt;br /&gt;
Useful debugging questions include: What is the value of each variable now? Which condition was true? How many iterations have occurred? Which variable changes the loop condition? What input makes the program stop?&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Choosing the Right Structure =&lt;br /&gt;
&lt;br /&gt;
Use a conditional when the program must choose among actions. Use a for loop when repetition follows a known count or collection. Use a while loop when repetition depends on a changing condition. Use nesting only when the problem itself has a nested structure, such as rows and columns.&lt;br /&gt;
&lt;br /&gt;
A flowchart can help you test the design before writing code. A decision symbol represents a true-or-false question, while an arrow returning to an earlier point represents repetition.&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart structured programming.svg|500px|frameless|center]]&lt;br /&gt;
&lt;br /&gt;
Good code is not only code that works. It should also be understandable. Meaningful variable names, simple conditions, predictable loop updates, and short blocks make logic easier to test and explain.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Real-World Applications =&lt;br /&gt;
&lt;br /&gt;
Conditional logic and loops are used whenever a digital system responds to changing information. A game can repeat its main loop while the game is active and use conditions to react to collisions. A weather station can repeatedly read a sensor and trigger a warning when a threshold is reached. A quiz app can loop through questions and use conditions to check answers. A data-cleaning script can examine each record and keep only items that satisfy a rule.&lt;br /&gt;
&lt;br /&gt;
These patterns also appear outside programming. A recipe can repeat stirring until a mixture is smooth. A sports drill can repeat for a set number of rounds. A school rule can be written as a decision: if a condition is met, choose one action; otherwise choose another. Turning such processes into algorithms helps you see where instructions are precise and where human judgment is still needed.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Interactive Tasks =&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Quiz: Test Your Knowledge ==&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What does a conditional statement do?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(It selects an action based on a condition)&lt;br /&gt;
(!It repeats every instruction forever)&lt;br /&gt;
(!It stores only text values)&lt;br /&gt;
(!It removes all variables)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What kind of value does a basic condition produce?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(A true or false value)&lt;br /&gt;
(!A file name)&lt;br /&gt;
(!A loop count only)&lt;br /&gt;
(!A picture)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;When is a for loop usually a good choice?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(When repetitions follow a known count or collection)&lt;br /&gt;
(!When no instruction should repeat)&lt;br /&gt;
(!When every condition must be false)&lt;br /&gt;
(!When a program has no data)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;When is a while loop usually useful?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(When repetition depends on a changing condition)&lt;br /&gt;
(!When a program must never repeat)&lt;br /&gt;
(!When only one variable may exist)&lt;br /&gt;
(!When all values are text)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is one pass through a loop called?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(An iteration)&lt;br /&gt;
(!A branch)&lt;br /&gt;
(!A syntax)&lt;br /&gt;
(!A comment)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What usually causes an infinite while loop?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(The loop condition never becomes false)&lt;br /&gt;
(!The program contains a list)&lt;br /&gt;
(!The loop has a variable name)&lt;br /&gt;
(!The code prints a message)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What does the Boolean operator AND require?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(Both conditions must be true)&lt;br /&gt;
(!Only the first condition must be false)&lt;br /&gt;
(!Exactly one condition must be true)&lt;br /&gt;
(!All variables must be numbers)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What is a nested loop?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(A loop inside another loop)&lt;br /&gt;
(!A condition without a result)&lt;br /&gt;
(!A variable that cannot change)&lt;br /&gt;
(!A comment inside a program)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What does a counter usually record?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(How many times something has happened)&lt;br /&gt;
(!The color of a flowchart)&lt;br /&gt;
(!The name of the programming language)&lt;br /&gt;
(!The size of every file)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{MC}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Why is a trace table useful?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(It shows how values and decisions change step by step)&lt;br /&gt;
(!It automatically writes every program)&lt;br /&gt;
(!It guarantees that code has no errors)&lt;br /&gt;
(!It replaces all testing)&lt;br /&gt;
&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Memory Game ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;memo-quiz&amp;quot;&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| Conditional || Chooses a path based on whether a condition is true or false&lt;br /&gt;
|-&lt;br /&gt;
| Boolean expression || Produces a true or false result&lt;br /&gt;
|-&lt;br /&gt;
| For loop || Repeats over a known count or collection&lt;br /&gt;
|-&lt;br /&gt;
| While loop || Repeats while a condition remains true&lt;br /&gt;
|-&lt;br /&gt;
| Iteration || One complete pass through a loop body&lt;br /&gt;
|-&lt;br /&gt;
| Sentinel || Special input that signals a repetition should stop&lt;br /&gt;
|-&lt;br /&gt;
| Counter || Variable used to record how many times something occurs&lt;br /&gt;
|-&lt;br /&gt;
| Nested loop || Repetition placed inside another repetition&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Drag and Drop ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;lueckentext-quiz&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Match the correct terms.&lt;br /&gt;
! Topic&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Select between alternatives&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Conditional statement&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Repeat across a collection&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| For loop&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Repeat while a rule stays true&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| While loop&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Combine required conditions&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Boolean AND&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;Track changing values step by step&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| Trace table&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Crossword Puzzle ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;kreuzwort-quiz&amp;quot;&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| Boolean || What kind of logic uses true and false values?&lt;br /&gt;
|-&lt;br /&gt;
| Iteration || What is one pass through a loop called?&lt;br /&gt;
|-&lt;br /&gt;
| Conditional || What kind of statement chooses a path based on a test?&lt;br /&gt;
|-&lt;br /&gt;
| Sentinel || What special input can signal that repetition should stop?&lt;br /&gt;
|-&lt;br /&gt;
| Branching || What general control-flow idea describes choosing among paths?&lt;br /&gt;
|-&lt;br /&gt;
| Counter || What variable is commonly increased to record repetitions?&lt;br /&gt;
|}&lt;br /&gt;
{{E}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== LearningApps ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe&amp;gt; https://learningapps.org/index.php?s=Conditional+Logic+and+Loops &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
== Cloze Text ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;quiz display=simple&amp;gt;&lt;br /&gt;
{&amp;#039;&amp;#039;&amp;#039;Complete the text.&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
|type=&amp;quot;{}&amp;quot;}&lt;br /&gt;
A conditional statement evaluates a { Boolean expression } to choose a path. The selected path is called a { branch }. A for loop is useful when repetition follows a known count or { collection }. A while loop continues while its { condition } remains true. One pass through a loop is an { iteration }. A variable that records how often something occurs is a { counter }. A special input that tells a loop to stop can be a { sentinel }. A loop inside another loop is a { nested loop }. Recording changing variable values can help you find { logic errors }.&lt;br /&gt;
&amp;lt;/quiz&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Open-Ended Tasks =&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Easy ===&lt;br /&gt;
# [[English:Decision Tree Poster|Decision Tree Poster]]: Draw a one-page flowchart for a familiar school decision, label each true and false branch, and explain where conditional logic appears.&lt;br /&gt;
# [[English:Everyday Loop Hunt|Everyday Loop Hunt]]: Find three repeated processes in daily life, write one sentence for how each process starts, repeats, and stops, and choose whether each is more like a for loop or a while loop.&lt;br /&gt;
# [[English:Loop Rhythm Experiment|Loop Rhythm Experiment]]: Create a short clap or movement pattern, repeat it a fixed number of times, then change it so that a condition decides when to stop; record what changed.&lt;br /&gt;
# [[English:Code Narration|Code Narration]]: Choose one short example from this course and make a one-minute audio or video explanation that narrates the program line by line.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Standard ===&lt;br /&gt;
# [[English:Input Validator Project|Input Validator Project]]: Design and code a small program that repeatedly asks for input until it meets a clear rule, then explain how the loop condition guarantees termination.&lt;br /&gt;
# [[English:Programmer Interview|Programmer Interview]]: Interview a programmer, robotics student, teacher, or coding-club member about one real bug involving a condition or loop; summarize the cause, debugging method, and fix.&lt;br /&gt;
# [[English:Survey Analyzer|Survey Analyzer]]: Collect a small anonymous class survey, loop through the responses, use at least one condition to classify them, and present the results in a table or chart.&lt;br /&gt;
# [[English:Computing Space Visit|Computing Space Visit]]: Visit a school computer lab, robotics club, makerspace, or suitable virtual coding environment and document two examples where repeated actions or decisions are used in a project.&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
=== Advanced ===&lt;br /&gt;
# [[English:Mini Game Controller|Mini Game Controller]]: Build a small text-based or visual game that has a repeating main loop, at least two conditional branches, a score or state variable, and a clear end condition.&lt;br /&gt;
# [[English:Algorithm Comparison Study|Algorithm Comparison Study]]: Solve the same repetition problem with a for loop and a while loop, test both versions with several inputs, and write a comparison of clarity, correctness, and risk of errors.&lt;br /&gt;
# [[English:Grid Art Generator|Grid Art Generator]]: Use nested loops to generate a grid, pixel pattern, or text image; predict the number of inner-loop executions before running the program and verify your prediction.&lt;br /&gt;
# [[English:Automation Proposal Video|Automation Proposal Video]]: Identify a repetitive task at school or home, design an algorithm that combines conditions and loops, and produce a two-minute video pitch that explains benefits, limits, and cases that still require human judgment.&lt;br /&gt;
&lt;br /&gt;
{{:Open Task - Create a MOOC}}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Learning Assessment =&lt;br /&gt;
&lt;br /&gt;
# [[English:Trace Table Analysis|Trace Table Analysis]]: Given a short program with a loop and a condition, create a trace table for every iteration and justify the final output from the recorded state changes.&lt;br /&gt;
# [[English:Boundary Case Testing|Boundary Case Testing]]: Design tests just below, exactly at, and just above a threshold, then explain what each test reveals about the conditional logic.&lt;br /&gt;
# [[English:Loop Selection|Loop Selection]]: For three different problems, choose a for loop or a while loop and defend each choice by referring to how repetition is controlled.&lt;br /&gt;
# [[English:Debugging Challenge|Debugging Challenge]]: Repair a program that has an off-by-one error or an infinite loop, identify the faulty logic, and explain why your correction makes the program terminate correctly.&lt;br /&gt;
# [[English:Nested Logic Design|Nested Logic Design]]: Create pseudocode for processing several items where each item must be classified by a condition, then explain how the loop and branch cooperate.&lt;br /&gt;
# [[English:Transfer Scenario|Transfer Scenario]]: Model a real process such as a game round, sensor monitor, quiz, or queue with conditions and loops, and evaluate one situation in which your algorithm would need further rules.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Evidence of Learning =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Knowledge:&amp;#039;&amp;#039;&amp;#039; You can explain control flow, Boolean conditions, branches, iteration, counters, sentinel values, for loops, while loops, nested loops, and common logic errors.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Skills:&amp;#039;&amp;#039;&amp;#039; You can trace variable values, predict outputs, choose suitable control structures, write clear pseudocode or code, test boundary cases, and debug faulty conditions or stopping rules.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Products:&amp;#039;&amp;#039;&amp;#039; Strong evidence may include a flowchart, trace table, tested program, debugging explanation, interview summary, data-analysis artifact, grid project, or explanatory video.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Transfer:&amp;#039;&amp;#039;&amp;#039; You can recognize decision and repetition patterns in unfamiliar problems, turn a real process into an algorithm, justify your design choices, and identify when a digital rule is too simple for a situation that requires human judgment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= OERs on the Topic =&lt;br /&gt;
&lt;br /&gt;
The English Wikipedia article on control flow gives broader background on branching and repetition in programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe&amp;gt; https://en.m.wikipedia.org/wiki/Control_flow &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= Linked Learning Areas =&lt;br /&gt;
&lt;br /&gt;
{| align=center&lt;br /&gt;
{{:D-Tab}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[[English:Conditional Logic and Loops|Conditional Logic and Loops]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# [[English:Control flow|Control flow]]&lt;br /&gt;
# [[English:Conditional (computer programming)|Conditional statements]]&lt;br /&gt;
# [[English:Boolean algebra|Boolean logic]]&lt;br /&gt;
# [[English:Loop (computing)|Loops]]&lt;br /&gt;
# [[English:Algorithm|Algorithm]]&lt;br /&gt;
# [[English:Flowchart|Flowchart]]&lt;br /&gt;
# [[English:Debugging|Debugging]]&lt;br /&gt;
# [[English:Python (programming language)|Python]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{BR}}&lt;br /&gt;
= aiMOOC Projects =&lt;br /&gt;
[[Category:English]]&lt;br /&gt;
[[Category:Conditional Logic and Loops]]&lt;br /&gt;
[[Category:Computer science]]&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Algorithms]]&lt;br /&gt;
[[Category:Grades 9-10]]&lt;br /&gt;
[[Category:AI_MOOC]]&lt;br /&gt;
[[Category:GPT aiMOOC]]&lt;br /&gt;
{{MT}}&lt;/div&gt;</summary>
		<author><name>Glanz</name></author>
	</entry>
</feed>