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 anif
statement! โ
Instead, use a variable to store theoutput
/return
value, andoutput
/return
it at the end โ
Conditionals, Loops, Mod #
๐พ ๐ฌ๐ป Write a method that outputs a checkerboard pattern of `#` and `_`.Remember, you can use
a mod b
ora%b
to find the remainder after integer divisiona//b
.
If the remainder is 0, that meansa
is evenly divisible byb
.
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 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 number
return:true
/false
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