Ongoing professional development and support is available throughout the year. Sign up for sessions and classes now.

# Pretest study guide for pseudocode, programming, algorithms and computational thinking

It is highly recommended that you review the official study guide and use the practice questions on pages 20-29 at https://www.ets.org/s/praxis/pdf/5652.pdf for College Board test 5652 CS Praxis II official study guide. Pay special attention to questions 2-4,6,12-13,20-25

### Pseudocode, algorithms, and the programming process

Computer programs must be very detailed in order to correctly control a computer. The computer itself operates in binary code, so people have created languages that are easier to read and understand for humans that are translated into machine language (binary code) for the computer.

A compiler is a program that translates a programming language (like Python, Java, Javascript, R, etc.) into machine code all at once and produces a compiled program that a computer can run independently.

An interpreter is a program that translates programming code piece by piece in a more interactive way. It is slower than a compiler but easier to uncover errors.

When programmers plan programs, they often write out their plan (also called an algorithm) in pseudocode, which is a somewhat precise way of describing the actual code to write without needing all of the details. There is a special pseudocode that has been created for the CS Praxis test that you should become familiar with on pages 13-14 of the official study guide: https://www.ets.org/s/praxis/pdf/5652.pdf

### Variables and assignment

Variables are named storage locations within a computer program. For example, if a program calculates the amount of carpet needed in a room it would need to know the length and width of the room so 2 variables would be created to store that information: length and width.

Assigning a value to a variable is indicated in pseudocode using an arrow symbol (←). The arrow points from the value being assigned toward the variable it is being assigned to. The following line of pseudocode should be read as 'width is assigned the value 34'.

`width ← 34`

The assignment operator can also be used to save the answer to an equation, as shown in the following examples:

`x ← a + b       x becomes equal to a plus b.x ← c - d * e   x becomes equal to c minus d times e. (NOTE: multiplication and division are processed before addition and subtraction)x ← e / f       x becomes equal to e divided by fx ← g ^ h       x becomes equal to g raised to the h power (ie: 2 ^ 3 is 2 to the third or 2*2*2=8)x ← i % j       x becomes equal to the remainder after i is divided by j (ie: 11 % 3 equals 2 because 11/3 is 3 with a remainder of 2)`

Similarly, we can also use the assignment operator for counting, by assigning a variable to become equal to the value of itself plus 1. Note that if x was equal to 7 before this statement is executed, it will be equal to 7+1, or 8, after the statement is executed.

x ← x + 1

Variables have types. Computers require different amounts of storage space to store whole numbers, decimals, words or pictures so when a variable is created it is assigned a type.

For the pretest the data types to be familiar with are the following:

1. int: a whole number using 4 bytes of storage that can have a value from -2,147,483,648 to 2,147,483,647
2. float: a number with a decimal point that uses 4 bytes of storage.
3. string: storage for a list of characters such as letters, symbols and digits.

Try these problems (answers are at the bottom of the page)

 1. What is the value of x at the end of this code? x  ←6 x  ←4 x  ←x * 2 2. What is the value of y at the end of this code? x  ←4 y  ←7 x  ←y - x y  ←y + x 3. Evaluate the following conditional expressions as true or false. 18 > 6 3 * 3 = = 16 – 5 4 ^ 2 £ 12 3 + 2 * 5 ¹ 5 ^ 2 8 / 4 + 2 ¹ 8 – 4 / 2 - 2 4. Use the following pseudocode to answer the questions: Int height ← 80 if (height > 75)    print “duck!” end if print “enter” What is the printed output of the pseudocode? What is the Boolean conditional expression? What is the largest value of height that will cause the program to print only “enter” Which is the assignment statement? 5. Use the following pseudocode to answer the questions: Int b ← 3 Int c ← 5 Int f ← 8 If ( b < c )    If (c < f )       b ← f    else       b ← c    end if else f ← b end if print b + “ “ + c + “ “ + f What will be printed? What will be printed if b ←10 ? What must be true to execute the code b ←c

### Usage rights of digital products. Creative Commons.

When digital products are posted online, Creative Commons outlines the requirements and options for legitimately sharing or using that work. The most common licenses are explained on the creative commons website.

compilers and interpreters

protecting software creations

Programming and expressions

Computers execute instructions sequentially from beginning to end. Variables allow programs to store information, modify it, and retrieve it.

A computer program that could calculate the monthly payment for a \$20,000 loan at 5% over

 1. What is the value of x at the end of this code? x  ←6 x  ←4 x  ←x * 2 First x is assigned the value 6 Then it is assigned the value 4 which replaces the old value 4*2 is 8 so in the end, x is 8 2. What is the value of y at the end of this code? x  ←4 y  ←7 x  ←y - x y  ←y + x At first, x is 4 and y is 7 X is assigned the value 7-4 = 3 Y is assigned the value 7 + 3 = 10 3. Evaluate the following conditional expressions as true or false. 18 > 6 3 * 3 = = 16 – 5 4 ^ 2 £ 12 3 + 2 * 5 ¹ 5 ^ 2 8 / 4 + 2 ¹ 8 – 4 / 2 - 2 True. 18 is greater than 6 False. 3*3=9 which is not equal to 16-5 which is 11 False. 4 squared is 16 which is not less than or equal to 12 True. Multiplication goes before addition, so 3 + 2*5 = 3 + 10 = 13 which is not equal to 5 squared which is 25. False. 8/4 is 2 + 2 = 4 and 8 – 4/2-2 = 8-2-2 = 4 so 4=4. 4¹4 is false.

 4. Use the following pseudocode to answer the questions: Int height ← 80 if (height > 75)    print “duck!” end if print “enter” What is the printed output of the pseudocode? What is the Boolean conditional expression? What is the largest value of heightthat will cause the program to print only “enter” Which is the assignment statement? duck! enter height > 75 75 height ← 80 5. Use the following pseudocode to answer the questions: Int b ← 3 Int c ← 5 Int f ← 8 If ( b < c )    If (c < f )       b ← f    else       b ← c    end if else f ← b end if print b + “ “ + c + “ “ + f What will be printed? What will be printed if b ←10 ? What must be true to execute the code b ←c 8 5 8 10 5 10 To execute b ←c; b must be less than c and c must be greater than or equal to f