CS1114 notes

CS1114 notes - Snake pit Can write any expression...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Snake pit Can write any expression Expression has a value and type - int (3) - str (“hi) -long (3333333333333333333333333333) -float (3.3) Type sometimes interacts with operators (+) -( / ) 1/3 is 0, 3 goes into 1; 0 times 1.0/3.0 is .3333333333 -The difference between operator + and regular + is how it is used - Operator overloaded (using the same + sign but for different meanings) -int + int = int -str + str = str -float + float = float -int + str = type error -float + int - 3, 4, 3 (Use , comma ) to keep on the same line. - #! Parentheses are not an operator (they are technically a punctuator!!!). They allow programmers to override the precedence but grouping subexpressions explicitly: 3 + 4 * 7 is not the same as (3 + 4) * 7. 7 / 4 = 1.75 7 // 4 = 1 7 % 4 = 3 is the remainder Associatively Left to right When ‘entered’ it evaluates the expression Defining a function A function is a tool you can use. -Should be reusable.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

CS1114 notes - Snake pit Can write any expression...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online