Section 02: Algorithms and Programming Flashcards
Define:
Algorithm:
A step-by-step procedure for solving a problem accomplishing some end
Ex: Recipe, assembly instructions, pseudocode, flowchart
What are the flowchart instructions?
Define
Program:
Translation of the algorithm using programming languages
Structure and details crucial
Define
Programming Languages
Formal languages designed communicate instructions to a computer
Low-Level vs. High-Level
Programs translate high to machine language:
- Compilers
- Interpreters
Differentiate
“Low-Level” and “High-Level” Programming Languages
-
”Low-Level” Languages: Language “spoken” by computer (binary systems)
- Hardware specific - must be specially made each brand computer
Categories:
1. *Machine language*: Directly understood computer & needs no translation (0100111100) 2. *Assembly language*: Easier humans understand than machine codes
-
”High-Level” Languages: PL use English and mathematical symbols to communicate instructions
- Easier to read & program
- Programs are PORTABLE (run on different kinds of computers)
Define
Compiler
- Translates high-level
- Once compiled, be run over and over again without needing to be retranslated
Define
Interpreters
- Translates source code line-by-line during execution
- No object code or executable
- If run code again, need run interpreters again
What is “Python”?
(1) High-level language & (2) interpreted language & (3) named after Monty Python
Advantages:
- Easy & concise
- Lots build-in functionality free and open source
- Can create pretty much any application
- Write using text editor
Define
Integerated Development Environment (IDE)
A program can be written using: An Integrated Development Environment (IDE) → Thonny ex
- Made specially for writing code:
- Syntax highlighting, auto-completion
- Can run code directly in IDE
- Debugging tools
Define
“Statement”
Ex: Print Statement
-
The Statement: Line of code preforms basic operation
- Above: print statement and parenthesis indicates that print is a function in python
// “print statement” use to disply specific stat
print(“Hello World!”)
Code
Comments (#)
-
Comments: Annotations (
#
)Function:- Make easier read and understands
- Choosing a good variable name can reduce num comments
Define
Bugs and Debugging
Bugs: Incorrect/unexpected results & process tracking down mistake ⇒ Debugging
Define & Code
Escape Sequences
Escape sequences: sequence characters represents special character
(1) \n
represents character “newline”
(2) \”
or \’
represent quotation mark
(3) \t
represents a tab
Define
Values
Basic things a program works with like n letter or num
- 2: integer
- 42.0: floating number point
- “Hello world”: string
If not sure about type of value; use type()
to find out