Compsci Test 1
Chapter 1
- Hardware
- Input Output typical hardware devices
- Input
- Data that the computer collects from people and other devices
- Input device
- Component that collects the data
- Keyboard, Mouse, Touchscreen, scanner, camera
- Disk drives can be considered input devices because they load programs into the main memory
- Output
- Data produced by teh computer for people and devices
- Text, Image, Audio, or bit stream
- Output device
- Formats and presents output
- Video Display, Printer
- Disk drives and USB, because data is send to them
- Central Processing Unit (CPU)
- The part of the computer that actually runs the program
- Software cannot run without it
- Used to be big
- Microprocessors
- CPUs on small chips
- Main memory (RAM)
- Where the computer stores a program while the program is running, and data used by the program
- RAM
- CPU is able to access data in RAM
- Contents are erased when the computer is off
- Secondary Storage devices
- Can hold data for a long time
- Programs are stored here and loaded to main memory when needed
- Types
- Diskdrive
- Solidstate drive
- Flash memory
- Software
- Application Software
- Programs that make computer useful for everyday tasks
- Email, Games, Webbrowser
- System Softwaree
- Programs that control and manage basic operations of a computer
- Operating system
- Utility Program
- Software Development tools
- CPU Cycle
- Fetch decode execute
- Fetch: Read the next instruction from memory into cpu
- Decode: CPU decodes fetched instruction to determine which operation to perform
- Execute: Perform the operation
- Binary
- Byte
- Just enough memory to sore letter or small number
- Divided into eight bits
- Electrical component that can hold positive or negative charge, like an on or off switch
- Compiler
- Translates high level language into program language
- Interperter
- Translates and executes instructions in high-level language programs
- Used in python
- Interprets one instruction at a time
\n
Chapter 2
- Input / Output
- Computer performs three step processes
- Recive Input
- Perform process on it
- Produce Output
- General Functions
- Function
- Piece of prewritten code that performs and operation
- Displays output on the screen
- Input function
- Variable = input(prompt)
- Always returns as a string
- String
- Characters used as data
- Enclosed in “”
- \
- Variables
- Assign variables
- Variable = expression
- Ex: age = 29
- Naming rules
- Cant be a keyword
- No spaces
- First character must be a letter or underscore
- Can use letters digits or underscores
- Case sensitive
- Reassignments and data types
- Garbage collection removes values that are no longer referenced
- Int
- No decimal point
- int(item) converts and item into and int
- Float
- Decimal point
- float(item) converts and item into a float
- Convert
- Comments
- Notes of explanation
- Start with #
- Math Expressions
- Modulus
- Division
- / floating point division
- // integer division
- Exponentation (exponent)
- (**)
- Multiplication
- (*)
- Remainder
- (%)
- Addition
- (+)
- Subtraction
- (-)
- Higher precedence performed first
- Same precedence is left to right
\n
Chapter 3
- Python Syntax
- If statement
- If condition is not true it just exits the structure
- If condition:
Statement
Statement
- If Else
- Understand flowchart
- If condition :
Statements
Else:
Other staments
If Elif Else
- Syntax
- Multiple if else statements
- Check first condition, if its true, check the second condition
- You can include multiple statements, not just two
- Look a the flow chart
Boolean
- Greater than less than
- == determines wether two operands are equal to each other
- ! = determines wether the two operands are not equal
- \
- True or false
Nested Expressions
Logical operators
Compare strings