import{_ as s,c as i,o as a,a4 as n}from"./chunks/framework.DtvhUNIn.js";const c=JSON.parse('{"title":"阶段一:熟悉语句","description":"","frontmatter":{},"headers":[],"relativePath":"技术资源汇总(杭电支持版)/3.编程思维体系构建/3.6.4.1阶段一:熟悉语句.md","filePath":"技术资源汇总(杭电支持版)/3.编程思维体系构建/3.6.4.1阶段一:熟悉语句.md"}'),t={name:"技术资源汇总(杭电支持版)/3.编程思维体系构建/3.6.4.1阶段一:熟悉语句.md"},p=n(`

阶段一:熟悉语句

🐱 在进行本章之前,请你谨记一个原则:基本所有的功能都被人提前实现好了

你需要关心的仅仅是逻辑该如何设立

在做本章任务前,请熟悉 python 的函数,循环和判断语句即可

P1:请仅使用一行语句求出三个数的最小平方和

python
def two_of_three(x, y, z):
    """Return a*a + b*b, where a and b are the two smallest members of the
    positive numbers x, y, and z.

    >>> two_of_three(1, 2, 3)
    5
    >>> two_of_three(5, 3, 1)
    10
    >>> two_of_three(10, 2, 8)
    68
    >>> two_of_three(5, 5, 5)
    50
    >>> # check that your code consists of nothing but an expression (this docstring)
    >>> # and a return statement
    >>> import inspect, ast
    >>> [type(x).__name__ for x in ast.parse(inspect.getsource(two_of_three)).body[0].body]
    ['Expr', 'Return']
    """
    return _____

提示:可以使用 min() 函数哦

P2:下降阶乘

python
def falling(n, k):
    """Compute the falling factorial of n to depth k.

    >>> falling(6, 3)  # 6 * 5 * 4
    120
    >>> falling(4, 3)  # 4 * 3 * 2
    24
    >>> falling(4, 1)  # 4
    4
    >>> falling(4, 0)
    1
    """
    "*** YOUR CODE HERE ***"

P3:判断一个函数是否有两个或者两个连续的 8

python
def double_eights(n):
    """Return true if n has two eights in a row.
    
    >>> double_eights(8)
    False
    >>> double_eights(88)
    True
    >>> double_eights(2882)
    True
    >>> double_eights(880088)
    True
    >>> double_eights(12345)
    False
    >>> double_eights(80808080)
    False
    """
    "*** YOUR CODE HERE ***"
`,9),l=[p];function h(e,k,g,F,d,r){return a(),i("div",null,l)}const y=s(t,[["render",h]]);export{c as __pageData,y as default};