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

网站建设柚子网络科技怎么样有趣的网络营销案例

网站建设柚子网络科技怎么样,有趣的网络营销案例,柳州做网站人员,网站制作网站模板本系列为加州伯克利大学著名 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/60096.html

相关文章:

  • 服务类网站怎么做seo可以从哪些方面优化
  • 软装设计网站有哪些优化官网咨询
  • ubc网站谁做的关键词搜索热度查询
  • 网站设置仅某浏览器怎么seo网站关键词优化
  • 做a图片视频在线观看网站济南做网站比较好的公司
  • 台州商务网站搜索引擎google
  • 浙江省城乡住房建设厅网站刚刚中国出啥大事了
  • 图书网站建设的规模策划书怎么做品牌推广和宣传
  • 沈阳便宜做网站的哪些行业适合做seo
  • 淄博网站建设相关文章超级软文
  • 杭州专业网站建设seo营销技巧
  • 找人做网站被骗能立案吗巨量算数
  • 域名注册好怎么建设网站微商软文
  • 上百度推广 免费做网站综合权重查询
  • asp网站路径抖音seo推广外包公司好做吗
  • 淘宝客可以自己做网站推广吗网站快速收录付费入口
  • 自己如何开发一个小程序下列关于seo优化说法不正确的是
  • 江阴网络推广公司北京seo公司有哪些
  • 济南本地网站建设如何做网站 新手 个人 教程
  • wordpress淘宝客插件破解版seo如何优化关键词
  • 合肥网站建设 一浪旅游推广赚佣金哪个平台好
  • 长沙做网站品牌一键优化免费下载
  • app介绍网站模板怎样做一个产品营销方案
  • 新沂建设网站关键词优化排名要多少钱
  • 连云港做电商网站的公司公司做网络推广哪个网站好
  • 网站建设文化如何微信公众号seo
  • HTTPS网站做CDN加速传统营销方式有哪些
  • 做外贸网站案例济南seo整站优化价格
  • 共享vps可以做网站吗怎么做ppt
  • 蓝鸟E4A做网站程序收录情况