Test 1 Mod 1-2 Flashcards
Program
set of instructions that a computer follows to perform a task
Commonly referred to as Software
Hardware
The physical devices that make up a computer Typical major components: Central processing unit Main memory Secondary storage devices Input and output devices
Byte
just enough memory to store letter or small number
Divided into eight bits
Bit: electrical component that can hold positive or negative charge, like on/off switch
ASCII
Most important coding scheme is ASCII
ASCII is limited: defines codes for only 128 characters
Unicode
coding scheme becoming standard
Compatible with ASCII
Can represent characters for other languages
CPU
designed to perform simple operations on pieces of data
Examples: reading data, adding, subtracting, multiplying, and dividing numbers
To carry out meaningful calculation, CPU must perform many operations
Key Words
predefined words used to write program in high-level language
Each key word has specific meaning
Operators
perform operations on data
Example: math operators to perform arithmetic
Syntax
set of rules to be followed when writing program
Statement
individual instruction used in high-level language
Compiler
: translates high-level language program into separate machine language program
Machine language program can be executed at any time
Interpreter
translates and executes instructions in high-level language program
Python uses an interpreter
Interprets one instruction at a time
No separate machine language program
Source Code
statements written by programmer
Program development cycle
Design the program Write the code Correct syntax errors Test the program Correct logic errors
Algorithim
set of well-defined logical steps that must be taken to perform a task
Psuedocode
Uses English-like phrases and terms to outline a task
Flowchart
Graphically depicts the logical steps to carry out a task
shows how the steps relate to each other
Function
piece of prewritten code that performs an operation
print()
string
sequence of characters that is used as data
String Literal
string that appears in actual code of a program
must be enclosed in single (‘) or double (“) quote marks
Variable
Name that represents a value stored in the computer memory
Used to access and manipulate data stored in memory
A variable references the value it represents
Input
function displays a prompt (based on argument passed to function call) and waits for user input
Float
() function converts the string value returned from the input function into a number (specifically, a floating-point number).
//
integer division that divides one number by another and gives the result as a whole number
%
Remainder division divides one number by another and shows the remainder
**
Exponent raises number to a power
Concatenation
taking multiple strings and combining them into a new string
when working with strings, the + symbol means concatenation
Augmented Assignemtn
An augmented assignment allows a variable to be part of the expression.
pay = + 20
pay += 20
Simultaneous Assignement
Multiple assignments in single statement
Split
method will take multiple input values and separate them. By default, it separates at the spaces, but a delimiter value could be used to separate on another character.
Escape Sequences
Backspace \b Tab \t Linefeed \n Backslash \\ Single Quote \' Double Quote \"
Delimeter
Character used in place of default character
end='delimiter' causes print() to place delimiter at end of data instead of newline character sep='delimiter' causes print() to use delimiter as item separator
Format
Can format display of numbers on screen using built-in format() function
Two arguments:
Numeric value to be formatted
Format specifier
Returns string containing formatted number
Format specifier typically includes precision and data type
Can be used to indicate scientific notation, comma separators, and the minimum field width used to display the value
Objects
all data—including numbers and strings—are actually objects.
Object
is an entity
each object has an id and a type
objects of the same kind have the same type
can use the id function and type function to get these information for an object
len()
len() returns the number of characters in the string
max()
max() returns the character with the highest value (ASCII)
min()
min() returns the character with the lowest value