CPSC120B
Fundamentals of Computer Science I
Day 3 Notes
Operators
Cool Computer Science Thing of the Day
Reading Questions
Quiz
Emacs Tip of the Day
- meta x, is hold alt, press x, then type a command
- “M-x customize-themes”
Assignment Posted
- actually multiple assignments, pick one
- scientific assignments
- graphical assignments
- physical computing assignments?
- with partner (put names in code)
- due in one week
Post-lab Review
- three variables, one print
- note the use of the variables in the print statement
- can change variable values and the program still works
- notice all of the decimal places we get, a little ugly and not useful
- could change to integer division
Operators
- We already know, and have used +, -, *, and /
- A few operators you may not have seen
- Integer division, //
- Always get whole number result, why is this useful?
- What if operand is float?
- Note what happens to type with /
- Mod or remainder, %
- Why is this useful
- Exponent, **
- Note the precedence of exponent
Errors
- some common errors you might see
- divide by zero
- spell a variable wrong
- use a variable before setting the value
- forgetting a parenthesis
- forgetting a comma
Lab