Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simple Python Data Victor Norman CS104 Calvin College.

Similar presentations


Presentation on theme: "Simple Python Data Victor Norman CS104 Calvin College."— Presentation transcript:

1 Simple Python Data Victor Norman CS104 Calvin College

2 Reading Quiz Counts toward your grade.

3 Data Type (or “class”) Everything has a type – Defines legal values and the operations you can do on those values. – integers: values = whole numbers; operations: add, multiply, etc. – strings: series of characters; operations: upper- case it, append to it, etc. Python must know what type of thing it is dealing with, always.

4 Literal Values Code must provide hints as to what type of thing you mean: – all digits  integer (int) – all digits and a dot  floating point number (float) – characters surrounded by quotes  string (str) – more to come…

5 Clicker questions

6 String Literals Can use single, double, triple-single, or triple- double quotes: – ', ", ''', """ Triple quotes useful for creating strings with quotes in them and/or newlines in them. Examples…

7 Type Conversion Functions Useful when you have a value that is the wrong type. – Really only needed by us when we read in a value from the user (which is always a str) and need to treat it like an int or float. Takes a value and produces a value of another type. Do NOT do this kind of thing: – float(3.14) – int(3) – str(“hello”)

8 Clicker Questions

9 Namespace and Objectspace Assignment creates/updates name in the namespace to refer to an object (new or existing) in the objectspace. Assignment steps: – evaluate the rhs (i.e., get a value for it) find object with that value or create it in objectspace. – Look up the name on lhs. if it does not exist, create it in the namespace. – Make name point to the value.

10 Clicker Questions

11 Assignment for Thursday Do TuringsCraft CodeLab questions before lab on Thursday. – These are graded and finishing before lab is crucial. Note for TC assignment: – you can print out multiple items on one line this way: x = 3 y = 4 print(x, y) print(“Result is”, x * y)


Download ppt "Simple Python Data Victor Norman CS104 Calvin College."

Similar presentations


Ads by Google