Class Notes (836,147)
CSC108H1 (113)
Lecture

# september 19 notes

2 Pages
139 Views

Department
Computer Science
Course
CSC108H1
Professor
Michelle Craig
Semester
Fall

Description
 Multi-valued assignment  Different types: A, B = 12, -400 o Integer = int A, B = , o “real” number = float o Both expression are evaluate before either resulting o picture = picture valued is assigned o pixel = pixel o So if variables a and b are used o color = color  quotations: o string of letters = str >>> word = „don‟t‟ o every python value has a type that describes what sort of value it is >>> world = “don‟t” o built-in function type will tell you the type of an >>> sentence = „He said “hello” to expression me‟  cast float value to int; or opposite >>> phrase = „‟‟ hello „bill‟. “Mary” „‟‟ >>> new_green = 5.4 >>> print phrase print int(new_green) hello „bill‟, “Mary” 5 >>> x = 7  Function “type” >>> float(x) >>> type(7) 7.0 o casting float to int drops the fraction >>> type(3.4) >>> x = 7.9999 >>> x = 5.43 >>> print int(x) >>> type(x) 7  Boolean = “true” or “false” >>> if average >= 90 … print „awesome‟ >>> not false >>> sunny = true true >>> sunny >>> sunny and snowing True false # both have to be true to >>> type (sunny) give true value, or else false >>> sunny or snowing >>> 3 < 4 true true >>> a = false >>> 3.5 >= 3.5 >>> b = true true >>> not a >>> x = 7 # assignment value true >>> x == 7 >>> not b true # double equal signs is false comparison command >>> a and b >>> y = 7.0 false >>> y == x >>> a or b true # even when two are different true types >>> not a or b # ??? precedence >>> 3 != 4 ???; evaluated as “(not a) or b” true or “not (a or b) >>> snowing = false true # (not a) or b  true ; not >>> sunny = true (a or b)  false >>> not snowing # not command >>> not not a flips “true” and “false” false True >>> x > 0 or x < 100 >>> not true true false  Assignments vs. equality o Pro
More Less

Related notes for CSC108H1
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.