Learning Python: CS 1
binary number system
first generation language (1GL), the same thing as the machine’s native language (machine language) where numbers represent the commands and data for the program
machine language are the binary numbers representing instructions that the computer interprets
machine language (binary) -> hexadecimal language
made it a bit easier to enter programs
assembly language
second generation language (2GL)
came later and made it even easier
each command uses a mnemonic and a program called a compiler changes the mnemonics into numbers that represent the commands
(but it’s still not very easy to program)
the next generation of languages allowed for higher-level abstractions
COBOL, FORTRAN, LISP
a compiler takes the program typed in by the user (source code) and turns it into machine code
a program compiled for windows does not work on a mac and so on
but a program can be run using an interpreter program that look at the source code and interpret it to machine language instructions on the fly
they are a bit slower but easier programming languages
python is an interpreted language; it must have a python interpreter to work and runs slower than c, but it’s easier to develop in python than c
there are specialised languages for different task:
c for operating systems
php for web pages
python for general purposes, easy to use
almost all languages share the same common elements, and once one language has been learned, the same theories will apply to the other languages
if you want to repeat a certain number of times, use a for loop. if you want to repeat until something happens (like the user clicks a button), use a while loop.
random numbers generated by python:
import random
randrange(min, max) generates an integer
random() generates a floating point number between 0 and 1