当前位置: 首页 > wzjs >正文

江津区建设委员会网站seo研究中心骗局

江津区建设委员会网站,seo研究中心骗局,设计的比较好的网站,西安做义工网站本系列为加州伯克利大学著名 Python 基础课程 CS61A 的课堂笔记整理,全英文内容,文末附词汇解释。 目录 01 Data Abstraction 数据抽象 Ⅰ Rational Numbers Ⅱ Rational Number Arithmetic 02 Pairs 对 Ⅰ Representing Pairs Using Lists Ⅱ Re…

本系列为加州伯克利大学著名 Python 基础课程 CS61A 的课堂笔记整理,全英文内容,文末附词汇解释。

目录

01 Data Abstraction 数据抽象

Ⅰ Rational Numbers

Ⅱ Rational Number Arithmetic

02 Pairs 对

Ⅰ Representing Pairs Using Lists

Ⅱ Reducing to Lowest Terms

03 Abstraction Barriers 抽象障碍

04 Data Representations 数据表示

Ⅰ What is Data?

Ⅱ Demo

Ⅲ Rational Data Abstraction Implemented as Functions


01 Data Abstraction 数据抽象

Compound objects combine objects together:

​        A date: a year, a month, and a day.

​        A geographic position: latitude and longitude.

An abstract data type lets us manipulate compound objects as units.

Isolate two parts of any program that uses data:

​        How data are represented (as parts).

​        How data are manipulated (as units).

Data abstraction: A methodology by which functions enforce an abstraction barrier between representation and use.

Ⅰ Rational Numbers

Exact representation of fractions is a pair of integers. However, as soon as division occurs, the exact representation may be lost !

Assume we can compose and decompose rational numbers:

Ⅱ Rational Number Arithmetic

#最上层def mul_rational(x, y):"""Multiply rational numbers x and y."""return rational(numer(x) * numer(y),denom(x) * denom(y))def add_rational(x, y):"""Add rational numbers x and y."""return rational(numer(x) * denom(y) + numer(y) * denom(x),denom(x) * denom(y))def equal_rational(x, y):"""Return whether rational numbers x and y are equal."""return numer(x) * denom(y) == numer(y) * denom(x)

rational(n, d) returns a rational number x.

numer(x) returns the numerator of x.

denom(x) returns the denominator of x.

These functions implement an abstract data type for rational numbers.

02 Pairs 对

Ⅰ Representing Pairs Using Lists
#最底层#A list literal: Comma-seperated expressions in brackets
>>> pair = [1, 2]
>>> pair
[1, 2]#"Unpacking" a list
>>> a, b = pair
>>> a
1
>>> b
2#Element selection using the selection operator
>>> pair[0]
1
>>> pair[1]
2#Element selection function
>>> from operator import getitem
>>> getitem(pair, 0)
1
>>> getitem(pair, 1)
2
#中间层def rational(n, d):"""Construct a rational number that represents N/D."""return [n, d] #Construct a listdef numer(x):"""Return the numerator of rational number X."""return x[0] #Select item from a listdef denom(x):"""Return the denominator of rational number X."""return x[1]
Ⅱ Reducing to Lowest Terms

from fractions import gcd #Greatest common divisor
def rational(n, d):"""Construct a rational number that represents N/D."""g = gcd(n, d)return (n // g, d // g)

03 Abstraction Barriers 抽象障碍

Violating abstraction barriers:

04 Data Representations 数据表示

Ⅰ What is Data?

We need to guarantee that constructor and selector functions work together to specify the right behavior.

Behavior condition: If we construct rational number x from numerator n and denominator d, then numer(x)/denom(x) must equal to n/d.

Data abstraction uses selectors and constructors to define behavior.

If behavior conditions are met, then the representation is valid.

Ⅱ Demo
#Rational arithmeticdef mul_rational(x, y):return rational(numer(x) * numer(y),denom(x) * denom(y))def add_rational(x, y):return rational(numer(x) * denom(y) + numer(y) * denom(x),denom(x) * denom(y))def equal_rational(x, y):return numer(x) * denom(y) == numer(y) * denom(x)def print_rational(x):print(numer(x), "/", denom(x))# Constructor and selectorsdef rational(n, d):return [n, d] def numer(x):return x[0] def denom(x):return x[1]
>>> x, y = rational(1, 2), rational(3, 8)
>>> print_rational(mul_rational(x, y))
3 / 16
# Constructor and selectorsdef rational(n, d):def select(name):if name == 'n':return nelif name == 'd':return dreturn selectdef numer(x):return x('n') def denom(x):return x('d')
>>> x, y = rational(1, 2), rational(3, 8)
>>> print_rational(mul_rational(x, y))
3 / 16
>>> x
<function rational.<locals>.select at 0x10293e6a8>
Ⅲ Rational Data Abstraction Implemented as Functions

附:词汇解释

latitude / ˈlætɪtuːd / 纬度、longitude / ˈlɑːndʒɪtuːd / 经度、represent 表示、manipulate / məˈnɪpjuleɪt / 操作、numerator / ˈnuːməreɪtər / 分子、denominator / dɪˈnɑːmɪneɪtər / 分母、fraction / ˈfrækʃ(ə)n / 分数、exact representation 精确表示、rational numbers 有理数、compose / kəmˈpoʊz / 构成、decompose / ˌdiːkəmˈpoʊz / 分解、arithmetic / əˈrɪθmətɪk / 算术,演算、constructor 构造器、selector 选择器、selection operator 选择操作符、bracket / ˈbrækɪt / 中括号、parentheses / pəˈrenθəsiːz / 小括号、lowest terms 最简形式、violate / ˈvaɪəleɪt / 违背、list literals 文字列表、element selection 元素选择、rational operation 有理运算、guarantee / ˌɡærənˈtiː / 确保、specify / ˈspesɪfaɪ / 明确指出,具体说明、met 符合、valid 有效的

http://www.dtcms.com/wzjs/436373.html

相关文章:

  • 网站开发项目策划网站流量统计分析工具
  • 怎样做网站操作向导视频广告
  • 普陀专业做网站济南网站建设方案
  • 导航网站建设bt磁力在线种子搜索神器下载
  • 深圳高水平网站制作东莞seo排名优化
  • 网站建设 博采北京网站推广机构
  • 网站后台不显示文章内容百度热搜广告设计公司
  • 网站推广应该怎么做最新军事新闻今日最新消息
  • 建建建设网站首页登封网站建设公司
  • 地方门户网站模板太原seo软件
  • 如何用ps做网站标识app推广代理加盟
  • 网站运营做哪些工作呢太原seo推广
  • 中国工程建筑门户网站官网百度竞价怎么做
  • 网站建设在开封找谁做微信加人推码35一单
  • 男女做暖暖的试看网站盘古百度推广靠谱吗
  • 电脑系统做的好的网站好国产系统2345
  • 如何自己制作微网站全国最新的疫情数据
  • 做网站怎么存放视频网络推广方案范文
  • i岗网站建设广州最新重大新闻
  • 那个网站是专门做机械设备定制网站多少钱
  • 十堰城市建设网站岳阳seo公司
  • 全面的网站建设seo准
  • 如何选网站空间网络推广培训班
  • apsx做的网站怎么发布百度seo优化排名软件
  • 网站建设服务套餐营销推广有哪些形式
  • 水利部建设与安全中心网站windows优化大师的功能
  • 温州网站推广模板网络营销策划书范文
  • 网站开发的人李海涛原创代写文章平台
  • 新公司网站怎么做推广自己的app如何接广告
  • 太原建站seo快排技术教程