Python Exam 1 Flashcards
How do humans solve problems?
cognitive abilities and intuition
How do computers solve problems?
Rely on computational power and algorithmic precision
different types of programming language
machine language, assembly language, high-level language
machine language
the limited set of instructions that a CPU can understand directly
Each instruction sequence of 1s and 0s
Binary digits or bits for shorts
the CPU executes the instructions
Assembly language
Each instruction is defined by a short abbreviation
The CPU can not understand assembly language directly –> translated into machine language using a processor
High-Level Language
For more readability and portability high-level language:
uses English like language
machine-independent
portable
examples: python, Pascal, C, C++, java, Fortron
Must be translated: 2 primary ways of translation: compiler and interpreter
2 primary ways of translation
compiler and interpreter
compiler
is a program that reads SOUCE CODE and produces a STAND-ALONE EXECUTABLE that can then be run
interpreter
program that directly executes the instructions in the source code w/o requiring them to be compiled into an executable first
About Python
high level general purpose
interpreted language
code executed line by line
run code without compiler
Why python?
relatively simple
pre-written software
widely used
general purpose
Python file extension
.py
What is a terminal also called?
terminal, console, output
string
a sequence of text characters
starts and ends with a “quote” character or a ‘quote’ character
quotes do not appear in output
String rules
strings surrounded by “” or ‘’ may not span multiple lines
strings surrounded by “” may not contain a “ character (unless using esc. seq)
strings surrounded by ‘’ may not contain a ‘ character (unless using esc. seq)
Escape sequence
used to represent certain special characters in a string
\t
\n
"
'
\
\t
tab key
\n
new line character
\”
quotation mark character
'
quotation mark/apostrophe character
\
backslash character
string addition
use plus operator +
comments
are notes written in source code by the programmer to describe/clarify the code
not displayed
# or “”” “””
Data types
a category or set of data values
constrains the operations that can be performed on data