Further programming language operations

Cards (106)

  • What is a string in programming?
    A sequence of characters stored as a variable
  • What characters can a string include?
    Numbers, letters, and symbols
  • How is a string represented in code?
    Enclosed in quotes, e.g., 'Hello'
  • What is a variable in programming?
    A memory location where values are stored
  • What data type can a variable have?
    A string as its data type
  • How do you determine the length of a string?
    Using the LEN function in pseudo-code
  • What does LEN(wordOne) return if wordOne is "Computer"?
    "eight"
  • How do you find a character's position in a string?
    Using wordOne[index] notation
  • What character does wordOne[2] return for "Computer"?

    "m"
  • What is a substring?
    A string of characters within another string
  • How can you extract a substring in pseudo-code?
    • Use a loop to concatenate characters
    • Use the SUBSTRING function
    • Example: SUBSTRING(0, 2, wordOne) gives "Com"
  • What is concatenation in programming?
    Joining together two or more strings
  • How do you concatenate strings in pseudo-code?
    Using the + operator between strings
  • What is the output of the concatenation of "Bob" and "Smith"?
    "Bob Smith"
  • What is casting in programming?
    Changing the data type of a variable
  • How do you convert a string to an integer in Python?
    Using int("54") returns 54
  • What does STRING_TO_INT do in pseudo-code?
    Converts a string to an integer
  • What is the purpose of CHAR_TO_CODE?
    Converts alphanumeric characters to numerical format
  • What character set does CHAR_TO_CODE use?
    ASCII or UNICODE
  • How does CODE_TO_CHAR function work?
    Converts ASCII/UNICODE to alphanumeric characters
  • How do you check if a character is between 'a' and 'z'?
    Using CHAR_TO_CODE for range checking
  • What does RANDOM_INT(97,122) generate?
    A random number between 97 and 122
  • What is the output of "does it contain" + CODE_TO_CHAR(character)?
    A question about a randomly generated letter
  • What is a subroutine in programming?
    A portion of code that can be called anywhere
  • What is the purpose of a subroutine?
    To perform a specific task in a program
  • Why are subroutines easier to write and debug?
    They are usually small in size
  • How do subroutines contribute to program efficiency?
    They allow code reuse, making programs shorter
  • What can subroutines be saved as for future use?
    Modules
  • What is a parameter in computer programming?
    A value passed into a function or procedure
  • How does passing data to a subroutine affect the main program?
    It allows the subroutine to be customized
  • What types of data can be passed as parameters?
    Integers, characters, and Boolean
  • Why is it beneficial to write code only once for subroutines?
    It results in shorter programs
  • What are the advantages of using subroutines in programming?
    • Code reuse saves time and effort
    • Easier to write, test, and debug
    • Makes programs shorter and more efficient
    • Enhances readability and understanding
  • What is the relationship between subroutines and the main program?
    • Subroutines are smaller sections of code
    • They can be called multiple times in the main program
    • They can be saved separately as modules
    • They help in organizing code effectively
  • What are the two types of subroutines?
    Procedures and functions
  • What is a procedure in programming?
    A subroutine that performs a specific task
  • What happens when a procedure completes its task?
    The main program continues from where it left off
  • What is an array in programming?
    A set of data values of the same type
  • What does the pseudo-code 'FOR count <- 1 TO lines' indicate?
    A loop that iterates from 1 to lines
  • What is a local variable?
    A variable used in one specific section of code