Paper 2 Programming Terms (Algorithmic Thinking) Flashcards
Input statement - string
variableName = input(“Question: “)
Input statement - whole number
variableName = int(input(“Question: “))
Input statement - decimal number
variableName = float(input(“Question: “))
Output statement
print (“Displays the information”)
Iteration - for loop (count controlled)
for loop in range (3):
print(“Repeats for set number”)
Iteration - while loop (condition controlled)
count = 0
while count < 5:
print (count)
count +=1
Selection - if/else
if day == “Saturday”:
print (“Yay - I love the weekend”)
else:
print (“I wish it was Saturday”)
Selection - if/elif/else
if day == “Saturday”:
print (“Yay - I love the weekend”)
elif day == “Monday”:
print(“ Yippee - a new week!”)
else:
print (“I wish it was Saturday”)
SWITCH Case
SWITCH day:
CASE ‘Saturday’:
print (“I love the weekend”)
CASE ‘Monday’:
print (“A new week!”)
default:
print(“I wish it was the Saturday”)
1-dimensional array/list
listName = [0,1,2,3,4,5]
listNames = [‘Array’, ‘Starts’, ‘At’, ‘Zero’]
2-dimensional array
ListOfLists = [[‘Sam’, ‘White’], [‘Alfie’, ‘Downing’], [‘Ivan’, ‘Williams’]]
Length of a string
length = len(variableName)
String - uppercase
upper = variableName.upper()
String - lowercase
lower = variableName.lower()
First 3 letters of string
LEFT (variableName, 3)
or
firstThree = variableName [:3]