Skip to content

Instantly share code, notes, and snippets.

View jjlumagbas's full-sized avatar

JJ Lumagbas jjlumagbas

View GitHub Profile
# Create a function that given a number,
# computes the value of the number times 2
# def twice(n):
# """
# (number) -> number
# Produce twice the value of the given number
# """
>>>def twice(x):
... return x * 2
...
>>>

Misconception: "Waiting" if and while

Researchers have found that some students hold the following misconception: if statements "wait" for their conditional statement to become true. When that happens (at whichever point in the program), the corresponding block of code is executed.

For instance, consider this program:

size = 0
if size == 5:
@jjlumagbas
jjlumagbas / 11-final.c
Last active December 23, 2015 08:23
My solution to CMSC11 Final last 4 questions
#include <stdio.h>
void display(int arr[], int length) {
for (int i = 0; i < length; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
// 1