Programming pre-assessment
The purpose of this programming pre-assessment is to evaluate your level or lack of programming skills in general. This assessment is agnostic of programming languages, which means that you can choose any language you are the most familiar with. It doesn’t have to be a programming language; you can even use English to write your program, which will be pseudocode. In any case, I need your working code. For example, you know little bit about Python syntax and decide to code in Python rather than in pseudocode; your code should run in Python with no errors. Remember that working pseudocode is always better than broken computer code. If you write pseudocode, I will run it in my brain. Don’t get discouraged even if you cannot answer any of these questions. I just need to understand where you are, so any results will help you and me. Please submit your answers in a plain text file named FirstLastname_Preassessment.txt to D2L.
1 Hello world!
10 points
Print Hello World!
.
2 Variables
20 points
Set $x$ to an integer. Calculate $x^2$.
3 Conditions
20 points
Set $x$ to an integer. If $x$ is positive, print positive
. If $x$ is zero, print zero
. Otherwise, print negative
.
4 Geometry
20 points
Set $w$ and $h$ to the base width and height of a triangle (i.e., $w=10$ and $h=15$). Calculate the area of the triangle and assign it to $A$.
5 Iteration
30 points
Implement the summation of squared integers from 1 to 100, $\sum_{i=1}^{100} i^2$ where $i$ is an integer. Use an iterative approach.
\[\sum_{i=1}^{100} i^2 = 1^2 + 2^2 + 3^2 + \cdots + 98^2 + 99^2 + 100^2\] or in general \[\sum_{i=1}^n i^2 = 1^2 + 2^2 + 3^2 + \cdots + (n-2)^2 + (n-1)^2 + n^2\]
6 Recursion
30 points
Implement the summation of squared integers from 1 to 100, $\sum_{i=1}^{100} i^2$ where $i$ is an integer. Use a recursive approach.
\begin{align*} \sum_{i=1}^n i^2 &= n^2 + \sum_{i=1}^{n-1} i^2\\ \sum_{i=1}^1 i^2 &= 1^2 \end{align*}
7 Combinatorics
30 points
A byte contains eight bits. A bit can represent either OFF (0) or ON (1). What is the maximum integer that an 8-bit unsigned integer can represent?
8 Data structure
40 points
Your program for an embedded system (e.g., an Internet-of-Things or IoT device) recognizes eight ON/OFF options (e.g., show temperature, humidity, etc.). However, this embedded system has very limited memory and only supports single-byte unsigned data types. The first and third options are ON while the other six options are OFF. Show me how you would store and extract the eight options in one single-byte unsigned variable named options
. Name the eight option variables option1
, option2
, ..., option8
, and use 0 for OFF and 1 for ON.