unit 7

Cards (105)

  • what is a data type
    the type of values used in variables
  • what are all the data types
    integer, float/real, string, boolean
  • what is an integer
    a whole number
  • what is a float/real
    a number with decimals
  • what is a string
    a sequence of characters
  • what is a boolean
    a true or false value
  • what does MOD do

    divides the 2 numbers but returns the remainder
  • what does DIV do

    integer division(truncates any decimals)
  • difference between=and==
    = is the assignment operator(assigns a value to a variable) == is a comparison operator(checks if two values are equal)
  • how would you output the first 3 characters of a string called 'name'
    name.left(3)
  • what value would name.left(5) return from the string 'quizlet'
    "quizl"
  • how would you output the last 3 characters of a string called 'name'
    name.right(3)
  • how would you output the character length of a string called 'name'
    name.length
  • how would you output thecharacters between the 2nd and 4th charactersof a string called 'name'
    name.substring(1,3)
  • what value wouldname.substring(2,10)return from the string "quizlet revision"name.substring(2,10)return from the string "quizlet revision"+

    izlet rev
  • how would you
    convert and printa string called 'name' touppercaseprint(name.upper)
  • what is
    indentationagapthat differentiates the lines included in each structure (e.g. for loops)
  • what is
    commentingtext that isignoredwhen the program is run, used totitle or explainspecific parts of code
  • what is a

    sequencea series of steps completedone after the other
  • what is a
    selectiona section of code that is only run if a condition is met(if/else, switch/case)
  • what is an
    iterationa part of a program thatrepeats(for...next, while...endwhile, do...until)
  • what are the
    comparison operators==(equal to)!=(not equal to)>=(greater than or equal to)<=(less than or equal to)>(greater than)<(less than)
  • what is the difference between
    if statementsandswitch/caseif statements- the value is compared to eachiforelsecondition using a comparison operatorswitch statements- the correctcaseis executed immediately if the condition is equal to the value
  • how would you output a
    random valuebetween0and10import randomprint(random.randint(0, 10))
  • why are
    forloops usedto repeat code aspecifiednumber of times.
  • why are
    whileloops usedto only repeat codewhilea certain condition is met
  • flowcharting a while loop
  • why are
    do...untilloops usedto repeat codeuntila certain condition is met
  • how would you
    declarethearraycalled 'usernames'array usernames[10]
  • how would you
    add"nickadoodle302" to the3rdindexin thearraycalled 'usernames'usernames[2] = "nickadoodle302"
  • how would you find the
    lengthof thearraycalled 'usernames'usernames.length
  • what is a
    subroutinea named block of code with a specific task that can be reused
  • what's the difference between a

    functionand aprocedurefunctions return a value at the end
  • how would you define and call a
    procedurecalled 'showMenu'procedure showMenu()
    print("Menu")

    showMenu()
  • what is a
    parameterthe values that get passed through a function
  • why are
    subroutinesused- they help to break up a large program into individual parts
    - each subroutine can be tested separately to ensure that it works
    - subroutines can be reused in other programs or multiple times in the same program
    - if there is an error, it only has to be fixed once and it will work throughout the program
  • what is a
    localvariablea variable that can only be accessedinsidea subroutine
  • what is a
    globalvariablea variable that can be accessedanywherein the program
  • what are the
    advantagesof usinglocalvariables- they help to keep a subroutine self-contained
    - they can be used without the variable names conflicting with others
  • what is a
    recorda data structure consisting of a number of fields which can all be of different types