Module 1 - the way of the program Flashcards
What is a program?
A set of instructions that tells a computer what to do (follows to perform a task, it specifies how to perform a computation)
Input
Data collected from input device (keyboard, network, file, hard drive)
Output
Data produced by the computer and displayed on an output device (screen, printer, save it in a file, send it over a network)
Conditional execution
Check for certain conditions and run appropriate code
What appears in almost every language?
Input/output, math, conditional execution, repetition
Python interpreter
A program that reads and executes python code
First three lines of python interpreter
Python 3.4 = version number
Operating system
Prompt (“»>” which means interpreter is ready for you to enter code)
How to display “Hello World!” in python
Print(“Hello world!”)
This is called a print statement
What do parenthesis indicate?
Function Print("Hello world") is a function
Arithmetic Operator
Special symbol in python that represents computations like addition and multiplication
What’s the arithmetic operator for exponentiation (exponents)?
**
So, 6**2 is 6^2 = 36
What does ^ mean in python?
Bitwise operator XOR
What is a value?
Basic unit of data, like a letter or number, that a program manipulates
What are the different types of values?
Integer, floating-point number, and string
If you’re not sure what the type is, how can you find out?
Ask the interpreter!
»>type(2)
(If you put ‘2’ it will show up as string)
Natural vs. formal languages
Natural languages (English, Spanish) evolved naturally and not designed by people Formal languages (Python, Math) are designed by people for specific applications, they have syntax rules, they are unambiguous, literal, concise
What is syntax? What are the two types of syntax rules?
Set of coding rules; tokens and structure
What are tokens?
Basic elements of a language, such as words, numbers, and chemical elements
For example, 3+=3$6 doesn’t work because $ is not a legal token in math
What are structure rules?
Pertains to the way tokens are combined
3+/3 is illegal in math because, although tokens are valid, you can’t have + and / next to each other
Parsing
Figuring out the structure of a language
Separating a string of commands and analyzing for correct syntax
Programming errors are called ___. What is the process of finding and correcting them called?
Bugs, debugging