Unit 2 - 2 Flashcards
What are variable assigned to?
An identifier and store a value in RAM
What is an identifier?
Must start with a letter and be a single word
Can variables be used to carry out calculations?
Yes
What does input ask for?
Computer will wait for a value from the user
What is casting?
Where variables and values can be converted to different data types
What is a string?
A variable that stores text rather than a number and is made up of a series of characters that can include spaces, symbols and numbers
What is concatenation?
Links things together, doing with the string using the ‘+’ operator
What is string traversal?
A software able to keep track of the position of every character within a string
How do you print the string length?
len(variable)
What is a ‘real’?
A decimal
What is ‘boolean’?
True or False
What is selection?
if variable == :
elif:
else:
What is a function?
from random import*
def identifier():
variable =
return variable
Define a procedure?
A block of code with an identifier which can be run anytime throughout a program
Give an example of a procedure?
def identifier():
What is an iteration loop, give an example?
variable =
count =
while count <=
variable = variable * count
print(variable)
count = count + 1
How do you break an iteration loop?
break
print(“end of loop”)
Iteration scenario - Output square numbers up to 144?
for x in range (1,13)
print(x**2)
What is an array?
A data structure that holds similar related data
What does an array store?
Similar, related data
What is the purpose of an array?
Reduces number of variables
What 2 things need to be declared to make an array?
Identifier + a size (number of elements it will hold)
What is the difference between 1D array and 2D array?
A 2D array can hold more than one set of data
How, using an array, would you find the name of the 3rd car in a set of data (SEE ONENOTE)?
third_car_name = cars[2]
REMEMBER ALWAYS STARTS AT 0