2.2 programming fundamentals

Cards (73)

  • What are the three programming constructs used to control the flow of a program?
    Sequence, Selection, Iteration
  • What does the Sequence construct in programming refer to?
    Structuring code into a logical, sequential order
  • How does the Selection construct function in programming?
    It involves decision making using if statements
  • What is the purpose of the Iteration construct in programming?
    Repeating code using for or while loops
  • What is the role of variables in programming?
    To store data in programs
  • What is the specification code for the OCR exam board related to data types?
    J277
  • What are the two parts of a variable?
    The data value and the identifier
  • What is a character in programming?
    A single character, such as a letter, number, or punctuation symbol
  • Give an example of a character data type.
    T
  • Why is it important to use sensible identifiers for variables?
    They help other programmers understand the purpose of the code
  • What is a string in programming?
    A sequence of characters, including letters, numbers, and punctuation
  • What is the difference between local and global variables?
    Local variables are used within a specific subroutine, while global variables can be used anywhere in the program
  • Provide an example of a string data type.
    Harry Waters
  • What is an integer in programming?
    A whole number
  • What are the advantages of using local variables in programming?
    They save memory and are easier to debug
  • Give an example of an integer data type.
    475
  • What are the advantages of using global variables?
    They can be used anywhere in the program and make maintenance easier
  • What is a real number in programming?
    A decimal number
  • What is an array in programming?
    An array is a static data structure that can hold a fixed number of data elements.
  • Provide an example of a real number data type.
    65.3
  • What is a constant in programming?
    Data that does not change in value as the program runs
  • What must each data element in an array be?
    Each data element must be of the same data type.
  • What is a Boolean data type?
    An answer that only has two possible values
  • Give an example of a constant in mathematics.
    Pi, which is approximately 3.14159
  • What is the index in an array?
    The index is a number that indicates the position of an element in the array.
  • Give examples of Boolean values.
    True / False
  • What are comparison operators used for in programming?
    To compare two data values
  • What is the index of the first element in an array?
    The first element in an array always has an index of 0.
  • Why are telephone numbers stored as strings instead of integers?
    Because they may contain leading zeros and special characters
  • What are the most common arithmetic operators?
    Add (+), Subtract (-), Multiply (*), Divide (/)
  • What does casting mean in programming?
    Converting the value of a variable from one data type into another
  • How can you traverse an array in programming?
    You can use a for loop to display each data element in order.
  • What does modulo division reveal?
    The remainder from the last whole number
  • What happens when you try to insert a new value into an array?
    You cannot insert new values, but you can change the value of existing elements.
  • In Python, which command is used to cast an input into an integer?
    int()
  • What is the result of 9%49 \% 4?

    1
  • What is the purpose of the str() command in Python?
    To cast a variable into a string
  • What does integer division reveal?
    The whole number of times a number can be divided into another number
  • What is the result of 9//49 // 4?

    2
  • What is an example of overwriting an element in an array?
    Overwriting the fourth element (Daphne) with a new value (Laura).