Cheatography
https://cheatography.com
This is a cheat sheet for ICS3U. A computer science course (for g11) in Ontario Canada
Computer Components and CalculationsGeneral process for all languages. Appearances may vary
Computer Components in ExcutionCPU + RAM = Program. CPU = 1 billion executions/sec. Steps called Machine Cycle.
CPU = Ctrl unitinstructions+ Logic(ALU)math
Calculating a single instruction:
1. Fetch 2. Decode 3. Execute 4. Store
internal clock: sync computer operations |
Programming Languages & Developing ProcessC.S: Math + Engineering + Science
Skill 1: Problem Solving
C.S: what can be computed? Solution -> Algorithm
High level Language User intrepretable (s.c)
Low level Language Machine interpretative
Processing High Level Languages:
1. Interpreting: (read and execute)
2. Compiling (translate completely)
Compiling VS Interpreting:
Once compiled, execute over and over
Interpreted program lets the user know bugs
Outcome Applications Software & OS |
| | Information processing cycle1: input 2: processing 3:output 4.storage |
Error TypesRun-Time Errors:
occurs when the program is running (e.g division by 0)
or using a undefined variable
Exception Handling:
detect cases where r.t errors would occur
Specific Exception Handling:
specifying the error type
argument of an exception:
you can capture an exception's argument by supplying a variable in the except clause
e.g
answer = raw_input("choose a, b, or c:")
if answer != "a" and answer !="b" and answer !="c":
raise ValueError("Question 1: Invalid Input: please enter a, b, or c")
else:
print "thank you"
except ValueError, errorvar:
print errorvar |
Variblesanything in quotes are assigned as a string
pure numbers are assigned as integers
decimal is assigned as float
Rules
Case sensitive
_use_underscore_for_spaces
must begin wiht letter
Using input input("text") lets user input what they want for the variable |
Data Typesint = integer
float = decimal
str = strings (words, letters, symbols)
Python Math
/ is for divide
** exponent
* multiply
+ add
- subtract
Use \" for double quotes in print statement
\t for tab
\n for line feed
\\ for backslash
# for comment |
| | IPO CHARTSGather input data
Process data
Output data |
T and Fx = 4
y = 5
z = x > y
print "The result of",x,">",y,"is",z
result : False |
Functions and Librariesint(<expr) convert to integer
float(<expr> convert an expression to float
abs(<expr>) return absolute value
round(<expr>) round off expression
pow(x,y) same as x**y
math.sqrt(c_sqrd)
Rounding off
round(pi,2) = 3.14 |
|
Help Us Go Positive!
We offset our carbon usage with Ecologi. Click the link below to help us!
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment