paper 2 all

Cards (50)

  • If statement example for pseudocode?

    if > 17 adult else child
    IF Age > 17 THEN

    OUTPUT "You are an
    adult"
    ELSE

    OUTPUT "You are a child"
    ENDIF
  • CASE OF example in pseudocode?

    n
    CASE OF OpValue

    "+" : Answer = Number1 + Number2

    "-" : Answer = Number1 - Number2

    "" : Answer = Number1Number2

    "/" : Answer = Number1 / Number2

    OTHERWISE OUTPUT "invalid operator")

    ENDCASE
  • For counter Pseudocode example?
    FOR Counter <- 1 TO 10 STEP 2
    OUTPUT Counter
    NEXT Counter
  • For counter python example with step 2?
    for Counter in range (1,10,2):

    print (Counter)
  • What is a count-controlled loops
    loop for a set number of iterations
  • What is a pre-condition loops

    may have no iterations
  • What is a post-condition loops

    always has at least one iteration.
  • what in python and pseudocode is a count-controlled loop
    FOR TO


    NEXT


    and


    for i in range ():
  • what in python and pseudocode is a pre-conditioned loop
    WHILE, ENDWHILE

    &

    while :
  • while loop in pseudocode
    WHILE TotalWeight <
    100

    TotalWeight = TotalWeight + Weight

    ENDWHILE
  • what in python and pseudocode is a post-conditioned loop
    REPEAT

    UNTIL

    or

    (python only uses pre conditioned loops
  • repeat pseudocode example
    REPEAT

    NumberOfItems
    = NumberOfItems + 1

    UNTIL NumberOfItems > 19
  • How do you find the length of a string in PS and PY

    LENGTH ("Computer Science")

    len ("Computer Science")
  • for substring in pseudocode how would you extract 'Science' from 'Computer Science'
    1st First parameter is the string

    2 second parameter is
    Position of the start character,

    3rdparameter is the length of the
    required substring.

    Pseudocode strings start at position one.

    SUBSTRING ("Computer Science", 10, 7)
  • substring in python?

    "Computer Science" [9:16]

    1st index is start position of substring

    2nd index is end position of substring

    python starts at position 0
  • how to do upper and lower case in pseudocode?
    UCASE ("Computer Science")

    LCASE ("Computer
    Science")
  • how to do upper and lower case in python?
    MyString.upper()

    "Computer Science". lower ()
  • file opening python

    f = open("demofile.txt", "r")
    print(f.read())
  • procedure
    perform certain tasks in a particular order on the basis of the given inputs.

    A procedure cannot be called using any function

    these can be called repeatedly, and we don't have to compile them every single time.
  • function
    calculate the results of a program on the basis of the given input.

    A function can be called using a procedure.

    compilation of a function occurs when we call them in a program.
  • file closing python

    f = open("demofile.txt", "r")
    print(f.readline())
    f.close()
  • writing to an existing file python
    f = open("demofile2.txt", "a")
    f.write("Now the file has more content!")
    f.close()
  • how to create and call a function in python?
    def my_function():
    print("Hello from a function")

    my_function()
  • how to delete in an SQL statement
    DELETE FROM table_name

    WHERE some_column=some_value
  • order by in SQl statemnt
    SELECT column_name(s)
    FROM table_name
    ORDER BY column_name [ASC|DESC]
  • select all in sql statement
    SELECT *
    FROM table_name
  • linear search

    Searching is used to check if a value is stored in a list.

    It is done systematically by working through all the items in the list.

    Linear search will inspect each item in a list in turn to see if it matches the value searched for.
  • bubble search

    When searching through lists it can sometimes be more effective if the list is already sorted.
    E.g. Names could be alphabetical and numbers could be in numerical order

    Here each element in the list is compared to the next one and swapped if the elements are in the wrong order.

    Starts with the first element and finishes at the next to last one.

    Once it gets to the end of the list we can be sure that the last element is in the correct place.

    It must now go back to the start and re do the process as other elements may still be out of order.
  • VA - Range checks

    checks that the value of a number is between an upper value and a lower value e.g checking percentage marks are between 0 and 100.
  • VA - Length checks

    checks that the data contains exact amount of characters e.g password can only be 9 characters
  • VA - Type checks

    Checks that the data entered is of a given data type e.g that the numbers of brothers and sisters would be an integer
  • VA - Character checks

    checks the number of characters meets
    expectations e.g 8 letter password needs 8 letters.
  • VA - Format checks

    checks to ensure the characters entered confrom to a pre-defined pattern e.g birth date - DD/MM/YY
  • VA - Presence checks

    checks to ensure that at least some kind of data has been entered and the value has not been left blank.
  • VA - Check digits

    check digit is the final digit included in the code, it is calculaed from all the other digits in the code. E.g Bardcodes and products codes
  • disadvantage of validation

    it cannot check that the data being entered is correct, it only checks to make sure it meets the requirements of the rules
    e.g. it can check a score is out of 100 but cannot tell that a score of 35 should have been 53
  • VE - Double entry

    - Data has been entered twice, if the two things match the propgram will move on but if they dont match then the program will alert the user to re input.
  • VE - Screen/visual check

    - a manual check is completed by the user who is entering data. The finished input data is displayed and the user must confirm if it is what they want to submit. If is not correct the user can reenter the data
  • VE - Parity check

    - check whether data has been changed if corrupted following data transmission, this method is based on the numbers of 1s in a byte of data.
  • VE - Checksum

    - a method to check if data has been changed or corrupted following data transmission. Data is sent in blocks, and an additional value called the checksum is sent at the end of the block of data.