What is Programming? Flashcards
Central Processing Unit
- the part of the computer obsessed with “what is next?”
- if computer is rated at 3.0 gigahertz, it means the cpu asks what’s next three billion times per second
Main Memory
- used to store information the CPU needs in a hurry
- nearly as fast as CPU
- info stored in main memory vanishes when computer is turned off
Secondary Memory
- also used to store info, but it is much slower than main memory
- can store even when there is no power to the computer (ex. Ssds and flash drives)
Input and output devices
- simply our screen, keyboard, mouse, microphone, etc
- all the ways we interact with the computer
Network connection
- the network is a very slow place to store and retrieve data that might not always be “up”
- the network is a slower and at times unreliable form of secondary memory
What is your role as a programmer?
We, the programmers, are the people who answers the CPUs what’s next question
Program
The stored instructions
Programming
The act of writing these instructions down and getting the instructions to be correct
What are the “reserved words”?
There’s a whole list BUT
- these words have a very special meaning to python
- when python sees these in a program they have one and ONLY one meaning to Python
What are the words you make up that hold meaning to python that aren’t the reserved words?
Variables
Variables
- as you write programs you will make up your own words that have meaning to you called VARIABLES
- you can use any name as a variable in python EXCEPT FOR THE RESERVED WORDS
- we use this term Variable to refer to the labels we use to refer to this stored data
- in algebra and symbolic logic- a variable is some unknown that we want to use in either statement, equation, etc.
- (within reason) we can create as many variables as we want
- sometimes we create them because the code needs them. Other times we create them to help us understand (ex. Circumference is d*Pi, but d can also be thought of as 2r)
Do CPUs understand English?
They only understand Machine Code. We use various translators to be able to understand this code and transmit it back to the computer
What is Python?
A high-level language intended to be straightforward to humans so we can use it to read and write to computers and so computers can read our inputs and process them
-python is a program itself and it is compiled into machine code
Interpreter
- reads the source code of the program as written by the programmer, parses the source code, and interprets the instructions on the fly
- python is an interpreter
Compiler
- needs to be handed the entire program in a file, and then it runs a process to translate the high-level source code into machine language. Then the compiler puts the resulting machine language into a file for later execution
- usually have a suffix of .exe or .dll which stands for “executable” and “dynamic link library”
How do compiled languages work?
-you write code, you compile it, the machine executes it (ex. C or C++)
What is the python interpreter written in?
A high level language called C
Example of Python interpreted
- you write code and hand it off to the interpreter(which is itself a program)
- the interpreter compiles it to bytecode
- the interpreter executes bytecode on a virtual machine
- the virtual machine converts bytecode to a machine code
- the physical machine executes it
For an interactive python experience (you conversing with the computer), what do you need?
All you need is an interpreter