2.2.1 Programming fundamentals Flashcards
What is a variable?
Value in your program that can change when program is running
What is a constant?
Value in your program that cannot change when program is running
What is a construct?
The building blocks of a program?
What are the 3 constructs?
Sequence
Selection (if statement)
Iteration (loop)
What is a sequence?
When code can run in the order that is written
What is an example of a sequence code?
1) A=5
2) B=6
3) Ans = A+B
4) print(Ans)
What is selection?
(if statement)
When code can jump to a different section based on location
What is an example of a selection code?
1) A=5
2) B=6
3) if A>B
4) print(A)
5) else
6) print(B)
What is iteration?
(loop)
When code repeats until condition is met
What are the two types of iteration loops?
Count controlled loop (for loop)
Condition controlled loop (while loop)
What is a count controlled loop?
(for loop)
Set a counter and you iterate that many times
What is an example of a count controlled loop?
for (i) in range (0,10) or (10)
print (name)
print(str(i)+name)
How can you count in twos in a count controlled loop?
for (i) in range (0,51,2):
print(i)
How can you count down in twos in a count controlled loop?
for (i) in range (50,-2,-2)
print(i)
How can you make your print go across the page in a count controlled loop?
for (i) in range (0,51)
print(1 , end = “ “)
What is a condition controlled loop?
(while loop)
Repeat a task while a condition is not met
What is an example of a condition controlled loop?
count = 0
while count != 10:
print(count)
count = count + 1
What does == mean?
Equal to
What does != mean?
Not equal to
What does < mean?
Less than
What does <= mean?
Less than and equal to
What does > mean?
Greater than
What does >= mean?
Greater than and equal to
What does + mean?
Addition
What does - mean?
Subtraction
What does * mean?
Multiplication
What does / mean?
Division
What does MOD mean?
Modulo
What does DIV mean?
Quotient
What does ^ mean?
Exponentiation (to the power)