This article explains what programming is inside the Computer Science Principles AP course and what other programming for beginners is not included.
AP Computer Science Principles (CSP) course
The AP Computer Science Principles (CSP) course is based in America but is taught elsewhere. Although it is an ‘advanced placement’ program, it presents beginner material to Computer Science in a limited area of fields.
Programming
Programming Language
There there is no set programming language for the Computer Science Principles AP course, although the AP CSP exam uses pseudo code for the programming questions.
The create task requires the use of a programming language, either a block-based language, like Scratch, or a text-based language, such as python, Java or JavaScript.
Published courses to help learn programming as part of CSP often use python, which is the language we would advise students to learn because of its usefulness and ease to learn.
If students are taking the Computer Science A course, or intend to take it, then it would be advisable to learn Java. Alternatives include JavaScript that is used on the Khan Academy website for the AP CSP course.
Programming in AP CSP
Basics
Conditionals
To make a choice we can use if statements. If a condition like ‘if age > 18’ is true then the following code is executed. If we want other code to run if the condition is not true then we can use an ‘if-else’ statement.
We can put one if or if-else statement inside another one, this is called a nested if statement.
The condition must be true or false therefore to use if statements we need to understand how to create these conditions. We can use a Boolean which is a variable with a value of either true or false.
Inside the condition we use comparison operators, such as greater than (>), less than (<), greater or equal to (>=), less or equal to (<=), the same as (==), or not the same as (!=). Using these operators in an if statement will check if something, the condition, is either true or false (e.g. age > 18).
There are also other operators called ‘and’, ‘or’ and ‘not’. These allow use to change the condition or use more than one condition. For example, age > 18 and name==”John”, age > 18 or name==”John”, or not age > 18.
Boolean logic
Loops
In programming we can repeat things, either continuously or for a set amount of times. We can use a for loop to repeat (or iterate) a set amount of times, or use a condition to run a while loop. Be careful as the while loop will run forever unless you either break from the loop or change it so that the condition becomes false.
Lists / Arrays
We store single items in variables and multiple items in lists, the same as in real life e.g. a list of names, a shopping list. In many programming languages the list is called an array.
To access an element in a lsit we use indexes and we can also split a list like sub strings using list slicing.
Functions
Programming not in AP CSP
We can separate the programming that is not in the AP CSP course into three categories: general, language-specific, and advanced. The advanced concepts would not be in year 1 of a computer degree course, or only included on the harder computer science degree courses.
General programming for beginners
In beginner courses for programming there are other area not covered in the CSP course. Examples include user input, handling files, other data structures, modules and libraries, and possibly more advanced areas such as objects, classes and pointers.
The initial introduction to programming courses at university focus on the primary concepts and use practice exercises and coursework to help students learn the syntax of the chosen programming language, whilst learning programming logic to develop programs.
Language-specific programming for beginners
Each programming language includes the common programming concepts but differs slightly. For example, in python the user input is always a string, even if the user enters a number. This means the data type is important although this is not fully discussed in the CSP course by some providers.
Another example would be the use of nested if statements in the CSP course which is allowed in programming but there are often better alternatives. In python there are if-elif-else statements and there are similar statements in the other languages. In C++ and Java case statements are often used when there are multiple options in a menu for example.
Advanced programming for beginners
Conclusion
The Computer Science Principles AP course covers most of the beginner material for learning programming and is therefore useful to take before learning at university or just learning about programming.
It is suitable for beginners and covers most of what you should know at the beginning but it is not exhaustive, there is much more to learn, but it is a good start.
What do you think about your experience learning about programming? Or, what do you want to learn about programming? Let us know in a comment.