Repetition part 1 Flashcards
Pseudo Code
fake code
write me a sentinel loop that add all the numbers tgt
Loop in a branch example
Branch in a loop example
end=” “ vs end=””
1 odd and 1odd
’<’ not supported between
instances of ‘str’ and ‘int’
wrire a code that adds all the sum of the number u enter before it. For ex: enter 4 (1+2+3+4)
When there is no branching/loops, the code runs….
Top to bottom (Sequential)
whether or not a part of the program repeats is determined by
a loop control
For loops: (2)
What it can do
- can count through a numerical sequence (1,2,3)
- iterate the sequence of characters in a string
For loops can only count trhough a
mumerical sequence through a sequence of addition or subtraction
While loop (2)
when it can be used
can be used any time repetition is needed
- can be used if its not know in advance how many times that loop will repeat
give me a countdown while loop example:
you cannot implement —– in For loop
logic
The only mathmatical operation you can do with For loop is
addition/subtraction