Additional Programming Techniques

Cards (46)

  • String manipulation

    The use of programming techniques to modify, analyse or extract information from a string
  • Case conversion

    The ability to change a string from one case to another, e.g. lowercase to uppercase
  • Length (string manipulation)

    Finding the length refers to the ability to count the number of characters in a string
  • Substring
    The ability to extract a sequence of characters from a larger string using slicing
  • Concatenation
    The ability to join two or more strings together to form a single string using the + operator
  • ASCII conversion

    The ability to return an ASCII character from a numerical value and vice versa
  • In Python substrings are indexed from 0
  • Python code

    • print(name.upper())
    • print(len(password))
    • print(FName + SName)
  • File handling

    The use of programming techniques to work with information stored in text files
  • Python code

    • file = open("fruit.txt", "r")
    • file.close()
    • file.readline()
    • file.write("Oranges")
  • "r" mode
    Used for opening a file in read-only mode
  • "w" mode
    Used for opening a file in write mode, creating a new file if it doesn't exist, or overwriting an existing file
  • "a" mode
    Used for opening a file in append mode, writing to the end of an existing file
  • It's important to make a backup of text files before working with them
  • Database
    An organised collection of data that allows easy storage, retrieval, and management of information
  • Field
    One piece of information relating to one person, item or object, represented as a column in a database
  • Record
    A collection of fields relating to one person, item or object, represented as a row in a database
  • Array (storing data)

    Useful when working with small amounts of data, stored in main memory (RAM)
  • Advantages of using a database

    • Efficient sorting and searching of large amounts of data
    • Multiple user access
    • Better security than text files
  • Disadvantages of using text files for data storage

    • It can be difficult to know where one record begins and ends
  • Advantages of using arrays for data storage

    • More efficient and faster to search than text files
  • When are text files useful for data storage

    Storing small amounts of data on secondary storage when the application is closed
  • SQL
    A programming language used to interact with a Database Management System (DBMS)
  • SELECT (SQL)

    The SELECT command in SQL is used to retrieve data (fields) from a database table
  • FROM (SQL)

    The FROM command in SQL specifies the table(s) to retrieve data from
  • WHERE (SQL)

    The WHERE command in SQL filters the data based on a specified condition
  • The '*' symbol is a wildcard in SQL
  • SQL commands

    • SELECT * FROM Customers;
    • SELECT name, age FROM Customers WHERE age > 30;
    • SELECT country, population FROM world WHERE population < 100000;
  • 1D array
    An ordered, static set of elements that can only store one data type
  • 2D array
    An ordered, static set of elements that can only store one data type but adds another dimension. It can be visualised as a table with rows and columns
  • Python code

    • temp = [1, 2, 3, 4, 5]
    • print(countries[1])
    • students[2] = "Rebecca"
    • scores = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
  • 2D arrays can only store one data type in the same array
  • Zero-indexing

    Indexes of an array start from 0, not 1
  • Function
    A type of sub-program that performs a specific task and returns a value
  • Procedure
    A type of sub-program that performs a specific task but does not return a value
  • Parameter
    A value that is passed into a sub-program (function or procedure)
  • To use a function/procedure it must be 'called'
  • Global variable
    A variable declared at the outermost level of a program and can be accessed from any part of the program
  • Local variable
    A variable declared within a specific scope, such as a function or code block, and can only be accessed within that scope
  • Key difference between function and procedure

    • A function returns a value, whereas a procedure does not return a value