Values and Variables
1 / 19
Values and Variables 1 / 19 Languages and Computation Every - - PowerPoint PPT Presentation
Values and Variables 1 / 19 Languages and Computation Every powerful language has three mechanisms for combining simple ideas to form more complex ideas:(SICP 1.1) primitive expressions, which represent the simplest entities the language is
1 / 19
◮ primitive expressions, which represent the simplest entities the
◮ means of combination, by which compound elements are built from
◮ means of abstraction, by which compound elements can be named
2 / 19
◮ Do strings always get printed with single quotes even if we diefine
3 / 19
◮ What’s the type of ’1’?
4 / 19
5 / 19
6 / 19
◮ How could we slighlty modify the expression above to evaluate to
7 / 19
8 / 19
9 / 19
◮ What hapens if you try to use a variable name on the list of
◮ What happens if you use print as a variable name?
10 / 19
11 / 19
◮ What happens if you evaluate the expression integer(’1’) ?
12 / 19
◮ with single quotes: ’Ni!’ ◮ double quotes: "Ni!" ◮ Or with triples of either single or double quotes, which creates a
13 / 19
14 / 19
◮ How does Python represent the value of the variable journey ?
15 / 19
◮ What is the index of the first character of a string? ◮ What is the index of the last character of a string?
16 / 19
◮ What is the relationship between the ending index of a slice and the
17 / 19
◮ Write a string slice expression that returns the username from an
◮ Write a string slice expression that returns the host name from an
18 / 19
◮ Values are the atoms of computer programs ◮ We (optionally) combine values using operators and functions to
◮ We create variables, which are identifiers that name values, define
◮ By choosing our identifiers, or names, carefully we can create
19 / 19