What programming is in AP Computer Science Principles (CSP)?

laptop for AP CSP

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 is a fundamental part of computer science and is therefore a major part of the AP CSP course. The course covers programming using text strings, mathematical functions and variables, whilst it also includes  programming logic. There are also several programming concepts covered in the course such as loops, lists and functions.
 
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
The AP CSP course includes the basics of programming, logic and some fundamental programming concepts. Perhaps there is more logic in the CSP course than in general courses for beginners, but everything else would be needed when learning programming at university.
 
The programming areas taught in the Computer Science Principles AP course can be split into the basics, conditionals, loops, lists and functions. Conditionals not only includes the if, if-else and nested if statements, but also Boolean logic.
 
Basics
The basics of programming learn at the beginning include print, operators, variables and mathematical and string functions.
 
To do simple mathematical calculations we use arithmetic operators like addition, subtraction, multiplication and subtraction. There are other functions available in programming to help with mathematical tasks.
 
We can also use built-in functions to do things with text, which is called strings in programming. For example, joining two words, or set of words together, or taking part of a string, called a substring, are included in the course.
 
To achieve our tasks in programming we can put these numbers or strings in a variable which can change when we wish. 
 
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
To make a choice we use the condition which is true or false. But there is also the use of logic in programming such as what makes a statement true or false.
 
For example, if you say “I’m not staying in”, or “I’m going out”, these have the same meaning. So going out is ‘true’ and staying is is ‘false’. As one is the opposite of the other then these are have the same meaning.
 
Another example would be that if the statement “it is not raining” is false, then it is raining. The logic says that false(false) is the same as true.
 
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
We have mentioned there are built-in functions to help with mathematical and string operations but you can also write your own. This is really useful as your code can get long and difficult to understand.
 
One method of helping organize your code is to use functions. You can also run the code in a function multiple times and even give it different values at different times.
 
To learn about functions we need to know how to define a function, how to call a function, how to pass to a function and how to return from a function.
 
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.

We will focus on the programming that a beginner should learn and that would be expected to be included at University in the introduction to programming 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
In a simple course for beginners there are not the more confusing aspects of programming, but on Computer Science degree courses these may well be included.
 
Object-orientated programming, multi-dimensional lists / arrays and pointers are more advanced programming concepts that are not on the AP CSP course and are more difficult to grasp for students.
 
Although these areas are important for computer science and programming, they are areas that you should learn after you have mastered the basics.
 
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.

Leave a Comment