ISF DP Computer Science

Review #

This page contains information and coding exercises for all our pseudocode topics: variables, loops, arrays, parallel arrays, searching, methods, sorting,collections.

Open up the pseudocode compiler in a new tab. You will be using this website to complete the exercises below.

๐Ÿ‘พ ๐Ÿ’ฌ

Make sure you are never using output/return inside an if statement! โŒ
Instead, use a variable to store the output/return value, and output/return it at the end โœ…



Conditionals, Loops, Mod #

๐Ÿ‘พ ๐Ÿ’ฌ

Remember, you can use a mod b or a%b to find the remainder after integer division a//b.
If the remainder is 0, that means a is evenly divisible by b.

๐Ÿ’ป Write a method that outputs a checkerboard pattern of `#` and `_`.

input: number of rows, number of columns
return: none

example output:

#_#_#
_#_#_
#_#_#
_#_#_
#_#_#


Collections, Array, Search, Mod #

A number is prime if it cannot be evenly divided by any number besides 1 and itself. For example 5 is prime, and can only be evenly divided by 5 and 1.

To check if n is prime, you can try dividing it by every number lower than n. If you are able to evenly divide it, it is not prime. If you try every number and none work, then it is prime.

๐Ÿ’ป Write a method that determines whether or not a number is prime.

input: a number
return: true/false

๐Ÿ’ป Write a method that searches through a collection. Each time it finds a prime number, it should add that prime number to a new array. It should return that array.

input: a collection of numbers
return: an array of all the primes found in the collection



Collections, Arrays, Loops #

๐Ÿ’ป Write a method that transfers the elements of a collection into an array, but in the opposite order. You may assume the collection has exactly 10 items in it.

input: a collection with 10 items
return: an array, which contains the same elements but in the opposite order



Deliverables #

โšกโœจ

Paste all your code in your Code Log