SQA Python

  • David Jack

    After noticing my pupils code is now getting better than mine I have decided to look at how I code Python and improvements I can make…..all while trying to do things that the SQA want me to do.

    I had an issue a few years ago at an understanding standards event when I was told

    print(name, " is ", age, "years old")

    could not be accepted as the print command does not concatenate.

    So now I teach

    print(name + " is " + str(age) + " years old")

    which is awful, but it is concatenation and I hope the SQA accept it. The kids trip up on it all the time.

    Now after doing some further reading I have been learning about formatting a print command

    print(f'{name} is {age} years old')

    Again this doesn’t strictly concatenate the code, but it is how it is done in Python. This is how it is taught outwith an SQA system. The pupils don’t need to worry about converting everything to a String and the same result is produced.

    I’m currently rewriting all my notes to trying and make my code more in line with whats expected in the real world all while trying to tick the SQA boxes.

    Can anyone pitch in with what the SQA expect from outputting values from variables? Would the formatted print command be accepted by the SQA?

    • This topic was modified 1 year ago by David Jack.
    David Jack

    Another great bit of code my pupils are using:

    names = ["David", "Billy", "Lisa", "Euan"]
     if "Brian" not in names:
        print("Brian does not appear")

    Unfortunately, at the moment I’m telling my pupils that they can’t use this code in class…..which seems wrong.

    Joe Stanfield

    I teach the same way; concatenate inside the print parameter. It’s messy and ugly.

    I would argue that the format method would not tick the SQA box of demonstrating concatenation, annoyingly, as in Python to concatenate, we need an operator (+).

    Sometimes the concatenation isn’t needed to be done for a print statement, instead it might need the concatenated data to be stored in a CSV file, in which case the concatenation would be done in the assignment of a new variable.

    username = firstname[0] + surname + str(birthYear)
    … for example.

    As for the second piece of code checking for an item not present, it’s efficient and makes sense, but it doesn’t demonstrate any use of iteration or selection with an elif/else which again is likely to be expected.

    names = ["David", "Billy", "Lisa", "Euan"]
    for i inrange(0,len(names)):
      if names[i] != "Brian":
        print("Brian has been found")
        print("Brian does not appear")
    Peter Thoresen

    I always use f strings. Concatenation in a print statement is bad Python as the command is both printing and concatenating. It’s better practice to concatenate and then print. Simple is better than complex.

    If concatenation is required for a task, then this has to be stated as a separate stage in the algorithm as in step 6 of the N5 2019 task (generate username).

    As to the use of IN, or BETWEEN commands. Pupils cannot be penalised for using knowledge beyond the course specification to complete tasks, unless they are explicitly told to use a command (eg in a fill the blanks question).

    David Jack

    Unfortunately, I think they can be penalised.

    numbers = [4, 6, 7, 8, 9, 34, 2, 3, 4]

    is code I see every year. Outwith the spec of the course and doesn’t demonstrate the skills the SQA require. The pupils don’t really understand why the have to do Find Max and Find Min but they do it anyways.

    Sean Stratton

    Yeah, I used in for the wordle task, for quickness but I don’t let the kids use it for the same reason as max and min.
    I had a coder a few years ago who was fantastic but kept using “shortcuts”. Trying to rein him in was soul destroying.


    Peter Thoresen

    Higher coursework tasks usually make it clear that min/max/count/index must be implemented “manually” – either from the algorithm or language such as “write a function to…”.
    This year’s task does not have that clarity. However, pupils must know that they are required to demonstrate and implement the standard algorithms from the course specification.


    This example does show concatenation. The , is provided to do the concatenation.
    print(name, ” is “, age, “years old”)

    Same with this. The curly braces are demonstrating concatenation. With concatenation simply being “joining things together”. Neither of these methods is doing anything not covered in SQA documentation.
    print(f'{name} is {age} years old’)

    The max / min things is a bit different. These are clearly described in SQA documentation as standard algorithms that have to be covered.

    David Jack

    McGivernj, I would agree with you – but at an understanding standards events I was told that it would not be accepted by the SQA.

    Mark Hay

    With a Higher marking and teaching hat on I would say that the print(name, ” is “, age, “years old”) isn’t concatenating. It is supplying two arguments to the print function to achieve the goal ( including adding spaces) so it is along the lines of using other predefined functions. ALso if they try to use that approach in an input statement such as input(“Please enter the mark for conestant”,x) it won’t work for them.

    I know there are different ways to achieve the same end and the syntax is a bit woeful at times though.

    Greg Reid

    Been reading your thread today. This is a question I get asked regularly with regards to the assignment.
    When I was teaching I invariably tried to think of programming in two ways.
    1. There’s a defined course I have to teach as that is what is being assessed. Teaching alternative solutions or the use of python functions/methods as shortcuts is not wise as students could potentially not prove that they can code, or answer questions on, the content of the course.
    2. If I had more able/keen coders then I wanted to push them, show them alternatives and discuss the pros and cons of each approach to create proper programmers. With those type of kids I found it fairly easy to have a discussion that went along the lines of “use max() when coding your own programs but remember in the assessment you have to prove that you can code the find max algorithm”.

    There’s a larger debate going on here about how externally marked assessments work. SQA have to be able to set an assignment that can be achieved in every language but then marked without favour to any one language. I can guarantee that this is not an easy task. A project style assessment offers the freedom to code your own solution but is very difficult to apply standardised marking instructions to (we saw that in the first version of N5). Having done both approaches now, which do you think is best?

    The use of predefined functions (one of the things I love about Python) could be solved by doing what England/Wales do, declare a programming language for their courses (usually Python now btw). With about 15 languages being used in Scottish schools, that creates a significant CPD/development workload for some departments but you could argue that the benefits that would bring to the assignment and the paper (no SQARL just one language that the kids are used to) may be worth the pain. I’d suggest that this would have to go hand in hand with teaching resources.

    I’ll leave you folks to discuss it here but if you’d like to email me at work with your thoughts feel free.

    David Jack

    I think you have hit the nail on the head when you mentioned standardised testing/assessment/marking over different programming languages. It’s very difficult to do and no matter how you try pupils who use one language may be disadvantaged than pupils who use another. Teachers end up bending the language to mimic another rather than showing off the true strength and benefits of their chosen programming language.

    Personally, I would favour one programming language to be used in all schools in Scotland, but I also know many teachers who have no interest in moving away from the resources/language that they have used for years.

    Lee Murray

    I have always been in favour of a single language for all schools. The CPD requirements has never struck me as a valid argument as we all had to do CPD for the N5 and Higher courses anyway. We all have to use SQL, HTML, CSS and JS, so why not specify the language for SDD?

    I personally wouldn’t mind learning a new language if it meant increased clarity on what was acceptable in exams and courseworks. The amount of time spent stressing about the teaching of functions, procedures, parameter passing, by value/reference, record strucutres etc. would far outweigh any stress of learning a new language.

    I always tell the pupils that the language they learn in school doesn’t matter as the knowledge of structures and algorithms is transferrable. It wouldn’t be a huge undertaking to learn a new langugage to teach. Adjusting materials would take a bit of time, but I don’t think I would even bother changing my materials if the course content doesn’t change.

    Regarding the question over concatenation, I’d be concerned if print(name, " is ", age, "years old") was a cause for deducted marks. However, I teach pupils to use the plus operator and to convert non-strings into strings. Partially to keep them thinking about data types, but also for the reason Mark mentioned about commas not working with the input function (or file.write operations).

    David Muir

    Standardised programming language? Is anybody else here old enough to remember COMAL?


    @David Muir I think these are the first two lines of the Computing Teacher’s blues.

    COMAL, Pascal, BBC BASIC;
    TrueBASIC, Visual Basic, Small Talk;
    Scratch, Kodu, HTML;
    LiveCode, Java, JavaScript;
    Python, Ruby, PHP;
    C, Perl or SQL;
    and not forgetting Logo!

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.