by Spencer Tiberi
1 pick up phone book
2 open to middle of phone book
3 look at names
4 if Smith is among names
5 call Mike
6 else if Smith is earlier in book
7 open to middle of left half of book
8 go back to step 3
9 else if Smith is later in book
10 open to middle of right half of book
11 go back to step 3
12 else
13 quit
pick up
, open to
, look at
, call
, open
, and go back
are functionsif
, if else
, and else
are conditionsSmith is among names
, Smith is earlier in book
, and Smith is later in book
are Boolean expressions
#include <stdio.h>
int main(void)
{
printf("hello, world/n");
}
#include <iostream>
int main()
{
std::out << "hello, world" << std::endl;
}
print("hello, world")
2 0 LOAD_GLOBAL 0 (print)
3 LOAD_CONST 1 ('hello, world')
6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
9 POP_TOP
10 LOAD_CONST 0 (None)
13 RETURN_VALUE
Java
class Hello
{
public static void main(String [] args)
{
System.out.println("hello, world");
}
}
Ruby
put "hello, world"
Lisp
(print "hello, world")
JavaScript
console.log("hello, world")
when green flag clicked
is equivalent to the start of your program
if else
counter
to 0cough
cough
3 times, abstracting away the complexitycough
will replace n!event
event
it can respondevent