dictionary of programming concepts


index.html code your own language

-> dictionary-of-programming-concepts
build-your-own-freedom-lab.html build-your-own-freedom-lab

quasi.html quasi

which-language-should-i-use.html which-language-should-i-use



list of entries

  1. constant values
  2. output
  3. variables
  4. input
  5. basic math
  6. loops
  7. conditionals
  8. functions


constant values

a value is a piece of information-- it can be a number, a string of characters (text) or anything else that the computer can represent as a series of 1s and 0s.
    examples:
"hello there"
-7.5
11

the first value is a string of text, the second value is a negative non-integer (known as a float value) and the third value is an integer. integers and floats are "numeric" values.

back to list


output

a type of command that moves information from the program to a device or file.
    examples:
print "hello world"
pset 5, 10
filename.write(p)

the first example puts text on the screen, the second places a dot at coordinates 5, 10 on the screen, the third example adds the contents of *p* to a file. *p* is a variable.

back to list


variables

a variable is a value that is given a name-- you can change the value, so the pairing is called a "variable".
    examples:
user = "roy"
height = 11.5
count = 100

back to list


input

a type of command that moves information to the program, from a device or file. typically the information is stored in a variable.
    examples:
height = raw_input()
inputfile = open("file.txt").read()

back to list


basic math

everything the computer does, consists of moving numbers around to numeric locations. the modern computer is a glorifed calculator with expensive outputs and inputs.
    examples:
variablename = secondvariable + variablename / 2
height = abs(int(raw_input()))


back to list


loops

a loop is typically a section of code, the top and bottom of which are marked with a pair of statements, a pair of braces, or levels of indentation.

the code between the top and bottom run repeatedly, until a condition (comparison of values) is true or a certain number of loops is reached.
    examples:

while
now print
wend

for p, 1, 10, 1
now = p ; print
next

for each in arrayitems:
print each

back to list


conditionals

the concept of program loops predate the modern (20th century) computer, and loops can have a conditional that tell them when to stop repeating-- a conditional is code that "loops" either 1 time or 0 times, depending on a condition.

the condition is typically a comparison of values. a condition of "true" is a value that is not equal to 0.
    examples:

if this_variable_is_not_0:
print "true"

ifmore p, 11
now = "p is not 11 or less" ; print
next

while
count = getcount p
ifequal count, 200
break # stops loop
next
wend

back to list


functions

functions help you organise code that is likely to be useful more than once in a program-- it is also like creating your own command, though it will only exist in programs where that command is defined. to add a function from one program to another, you either need to "import" the command from a library, or copy the code into the new program.

since basically all commands in a programming language are sections of code that are called by their name, you can refer to commands in a language as "functions" or "routines". in oop languages, a function is also known as an "object method".

functions are "defined" (created) and then "called" (run from the program.) as with any other command, you call a function by using its name. you define it by writing code in it:
    examples:

# a python function
def greet(p):
print "hello, " + p

# a fig function
function greet p
now = "hello, plus p is not 11 or less" ; print
next

# calling a python function
greet("rms")

# calling a fig function (the = sign is optional)
now = greet "milo"

back to list


happy coding!