Additional Programming Techniques

Cards (13)

  • Concatenation
    • The ability to join two or more strings together to form a single string
    • Concatenation uses the '+' operator to join strings together
  • Files have two modes of operation - read from and write to.
    • To open a file, it must be referred to by its identifier, for example:
    • file = open("demofile.txt","r")
    • This would open the file and allow its contents to be read.
    • file = open("demofile3.txt","w")
    • This would open the file and allow it to have data written to it.
    • file = open("demofile2.txt", "a")
    • This would open the file and allow you to append it.
    • file.close()
    • This would close the file
  • SQL Commands examples:
    • SELECT * FROM "personnel" WHERE "Title" = "Mr"
    • SELECT * FROM "personnel" WHERE "email address" LIKE "%com"
    Note - * stands for wildcard, which means all records. This would retrieve the following data:
  • Databases use their own type of programming language. This language is known as structured query language, or SQL.
  • Write an algorithm in pseudocode to:
    • store "Hello" in the variable word1
    • store "Everyone" on variable wprd2
    • concatenate word1 and word2 to store "HelloEveryone" in variable message
    word1 = "Hello"
    word2 = "Everyone"
    message= word1 + word
  • Subroutine
    A named section of code that can be called and reused
  • Built-in
    Premade by Python
  • user-defined
    Created by the programmer
  • method
    A subroutine that works on variables
  • function
    A subroutine that works on any value given
  • parameter
    The value/s that are passed through the brackets
  • procedure
    a function that gives no value