2.Core Elements of Programs

2017-03-17  本文已影响0人  诵成读书

2.Core Elements of Programs

一、Programming Language


思路分析:

IngredientIngredient IPython知识结构图IPython知识结构图

1.Programming Language

Goal:

2.Operations for programming languages


3.Python programs

二、Objects and Expressions


4.Objects

5.Expressions

6.Operators on ints and floats

7.Some simple examples

> > > 3 + 5
 8
>>> 3.14 * 20
62.8
>>> (2 + 3)*4
20
>>> 2 + 3*4
14

8.Performing simple operations

9.Comparison operators on ints and floats

10.Operations on bools

11.Type conversions(type casting)

12.Simple means of abstractions

13.Binding variables and values

14.Changing bindings

三、Non-scalar objects


15.Non-­‐scalar objects

16.Operators on strings

17.Extracting parts of strings

18.Programs (or scripts)

–  print(‘ab’)
–  print(‘3’*3)

19.Provideing input

20.Some simple code

四、Three types of Programs


21.A straight line program

22.Some observations

23.Branching programs

24.A simple example

25.Some observations

26.We can have nested conditionals

27.And we can use compound Booleans

28. What have we added?

IMG_3168IMG_3168 IMG_3169IMG_3169 IMG_3170IMG_3170

Eric Grimson: Welcome back to 600x.
In this second lecture we are going to start developing knowledge of programming languages.
We'll talk about how a computer converts a description of a how-to method that we write in a high level, although a semantically constrained manner, into a set of instructions that its internal circuitry can execute.
To do this, we're going to begin to introduce the basic elements of Python, the language we're going to use in this course.
We will introduce a bunch of things.
Numbers, expressions that combine numbers arithmetically, ways to compare objects like numbers, Boolean operations on logical expressions, ways to abstract expressions by giving them names, strings or collections of characters and words and operations on them, combining expressions in a linear manner, and simple ways to make decisions and to take different options or branches based on those decisions.
At the end of this lecture, you should be able to write simple programs that manipulate numbers or strings, make decisions, and print out results.

上一篇 下一篇

猜你喜欢

热点阅读