Foundations of Programming
Foundations of Programming
Your Progress
Learning goals
Learn about basic programming concepts like functions, operators, variables, control flow, strings, and arrays — some of the building blocks of programming.
Suggested prerequisites
No experience needed!
Variables & Operators
Variables allow you to store values for later use. For example, you can store the value "Kevin" in the variable myName. Operators are symbols that allow you to perform arithmetic (e.g. adding two numbers), comparisons (e.g. comparing two values to see which is greater), and logical operations (e.g. checking if one of two things is true).
What are variables?
What are variables and why are they useful? Learn how to store values in your programs with variables by watching this video from Code.org's series on CS Principles. (YouTube)
ESTIMATED TIME: UNDER 10 MINSTutorial: Variables (Python)
Variables act as "storage locations" for data in a program. Practice using variables with this guided Python tutorial from the University of Waterloo. (CSCircles)
Operators used in programming
Watch this video to learn about what operators are, what different types exist, and how you can use them to compute data in your code. (YouTube)
ESTIMATED TIME: 10-20 MINSTutorial: Operators
An operator is a symbol that tells your program to perform logical operations. For example, a plus sign operator is used to add numbers! Learn about available operators and how they're used in coding. (TutorialsPoint)
Evenly spaced (Java)
Try this question to determine whether 3 given numbers are evenly spaced, or that the difference between the small and medium number equal the difference between the medium and large number. (CodingBat)
Make bricks (Java)
Interested in learning how to use the modulo operator? Get some practice by solving this problem where you'll use the modulo operator to check whether it's possible to make a row of bricks. (CodingBat)
Make bricks (Python)
Interested in learning how to use the modulo operator? Get some practice by solving this problem where you'll use the modulo operator to check whether it's possible to make a row of bricks. (CodingBat)
Test your knowledge of variables & operators!
Test your knowledge of variables and operators with this short quiz. Even if you're not an expert, this quiz will give you immediate feedback to help you better understand the concepts.
ESTIMATED TIME: UNDER 10 MINS
If Statements & Loops
If statements allow you to run a specific block of code only if a condition is true. For example, you may increment a variable myAge only if it's your birthday. Loops allow you to run a block of code repeatedly. For example, you may write a loop that draws a circle 10 times.
If statements explainer
Learn about control flow in programming, including the fundamental concept of if statements, in this helpful video from Udacity's Programming Languages course. (YouTube)
ESTIMATED TIME: UNDER 10 MINSIf statements tutorial (Python)
If statements' allow you to perform actions only when certain conditions are met. Learn more about if statements and control flow in programming from this tutorial with examples to guide you. (CSCircles)
Else statements & boolean operators (Python)
Learn about else statements and boolean operators, such as and, or, or not, from this interactive lesson! While this lesson highlights Python, the concepts can be applied to any programming language. (CSCircles)
How to write if statements (C++)
Want to create decision-making programs in C++? Learn how you can take advantage of the if statement to do just that! (Programiz)
ESTIMATED TIME: 20-30 MINSHow to write if statements (Java)
Want to create decision-making programs in Java? Learn how you can take advantage of the if statement to do just that! (Programiz)
ESTIMATED TIME: 20-30 MINSBlackjack (Java)
Let's practice using conditionals in this coding problem. You can take advantage of if statements to check which one of the given input values is closest to 21. (CodingBat)
Loops tutorial (Python)
Want to brush up on the basics of loops? Check out this tutorial that includes interactive examples and a practice problem at the end to test your knowledge. (LearnPython)
Loops tutorial (Java)
Want to brush up on the basics of loops in Java? Check out this tutorial to learn about different types of loops, such as for and while loops, and complete an exercise to test your understanding. (LearnJava)
How to write loops (C++)
In programming, loops are used to repeat an action on a block of code. Brush up on the basics of for loops in C++ with this article, which includes example problems and solutions. (Programiz)
ESTIMATED TIME: 20-30 MINSSearch for number sequence (Python)
Want to get practice with writing loops? Try your hand at this practice problem to determine whether a given sequence of numbers can be found in an array. (CodingBat)
Compute factorial
Put your loop-writing skills to practice by solving this coding question where you'll compute the factorial of an input value. (coderbyte)
Functions
A function is a block of code that has a name. When you "call" that function, the code inside it will run. You've probably called functions in code you've written (e.g. "print", "System.out.print")
Programming basics: statements and functions
Did you know that you can create a video game using conditional statements? Check out this video to learn about control flow in programming and how you can use the concept to create your own games! (YouTube)
ESTIMATED TIME: 10-20 MINSHow to write functions (C++)
Interested in learning the basics of functions in C++? Check out this tutorial to learn more about the C++ function and function expressions with the help of examples. (Programiz)
ESTIMATED TIME: 20-30 MINSHow to write functions (Python)
Functions are great because they help break down larger programs into smaller chunks! Learn more about how to define your own functions in the Python with this tutorial! (Programiz)
ESTIMATED TIME: 20-30 MINSHow to write functions (Java)
Methods are commonly used in the Java language to define the behavior of a class. Check out this tutorial to learn all about functions, including how to declare and use them. (Programiz)
ESTIMATED TIME: 20-30 MINSProduct & sum of digits
Interested in getting practice with mathematical operators in programming? Check out this coding question where you'll take advantage of operators to solve a mathematical question. (LeetCode)
Strings
Strings are an collection of characters in a specific order. Strings are used to store values like "Hello world!"
Strings (Java, C++)
In computer science, a string is an array of characters. Learn more about strings and the unique operations that can be applied to them in this LeetCode tutorial with examples to help guide you. (LeetCode)
Reverse a string
In this practice coding question, you'll write a function that reverses a string. You can even use it to check whether or not a word is a palindrome! (coderbyte)
String Splosion (Java)
In this practice coding question, you'll write a function that takes a string like "Code" as input and returns a string like "CCoCodCode" in Java. (CodingBat)
String Splosion (Python)
In this practice coding question, you'll write a function that takes a string like "Code" as input and returns a string like "CCoCodCode" in Python. (CodingBat)
Longest word in string
In this practice coding question, you'll find the longest word in a sentence. Don't forget to add it to your vocabulary! (coderbyte)
Repeated String
In this practice question, you'll count the number of occurrences the letter 'a' appears in a string. The solution you come up with could even be applied to count the number of occurrences in a dataset! (HackerRank)
Test your knowledge of strings!
Test your knowledge of strings with this short quiz. Even if you're not an expert, this quiz will give you immediate feedback to help you better understand the concepts.
ESTIMATED TIME: UNDER 10 MINS
Arrays/Lists
Arrays (also known as Lists) are a data structure that allows you to store a collection of items in a specific order. Each item in an array can be quickly accessed by using its index (i.e. location) in the array.
Intro to arrays
Want to dive deeper into the world of arrays? Watch this helpful Khan Academy video to learn how to store a sequence of multiple values in one variable, using arrays. (YouTube)
ESTIMATED TIME: UNDER 10 MINSArrays tutorial (Java)
What are arrays and what are they used for? Find out from this LeetCode tutorial, which is divided into chapters each covering an aspect of arrays. It also includes practice problems for you to solve. (LeetCode)
How to use arrays (C++)
In C++, an array is a variable that can store multiple values of the same type. Learn more about arrays in this tutorial and how you can use them to declare, initialize, and access elements. (Programiz)
ESTIMATED TIME: 20-30 MINSFind centered average (Python)
In this practice coding problem with a twist, you'll compute the mean average value in an array of numbers...ignoring the largest and smallest numbers in the array! (CodingBat)
Find intersection
Finding commonality, or intersections, among two pieces of data is a useful skill to learn in computer science. Practice this skill by finding the intersection between two lists of numbers. (coderbyte)
Sort array by parity
Looking to practice your sorting algorithm skills? Try this practice problem where you have to order the elements based on whether they're even or odd. (LeetCode)
Test your knowledge of arrays/lists!
Test your knowledge of arrays/lists with this short quiz. Even if you're not an expert, this quiz will give you immediate feedback to help you better understand the concepts.
ESTIMATED TIME: UNDER 10 MINS