VSCode 配置 python Lab00 python3 ok --help: 查看 ok 提示。 python3 ok -q <file> -u: 运行单个 tests 目录下的测试。 python3 ok -q <function>: 运行单个函数的测试。 python3 ok: 运行全部测试。 python3 ok --score:查看分数。 python3 ok --local:本地运行测试。 python3 -m doctest lab00.py: 运行 doctest。 python3 -i xxx.py: 进入 python 交互模式 python3 -m doctest xxx.py: 运行函数的 doctest,如下,会运行»>后的函数,并与 2024 对比。如果 pass 的话不会有任何输出。 def twenty_twenty_four(): """Come up with the most creative expression that evaluates to 2024 using only numbers and the +, *, and - operators....
Posts
Building Abstractions with Data 2.1 Introduction 2.1.1 Native Data Types Python includes three native numeric types: integers (int), real numbers (float), and complex numbers (complex). >>> type(2) <class 'int'> >>> type(1.5) <class 'float'> >>> type(1+1j) <class 'complex'> 2.2 Data Abstraction 2.3 Sequences 2.3.1 Lists >>> digits = [1, 8, 2, 7] >>> len(digits) # 返回list长度 4 >>> digits[3] 8 >>> digits[-1] # 最后一个元素 7 # 这样也可以取list中的值 >>> digits = [1, 2, 3] >>> x, y, z = digits # 注意这边必须和list中元素的数量对应上才能unpack >>> x 1 >>> y 2 >>> z 3 List 的加法和乘法:...
Chapter 4 Data Processing 4.2 Implicit Sequences Sequence 可以在使用时才分配内存, 比如下面的 range(), 只有在使用时才分配内存, 而不是在定义时分配内存. >>> r = range(10000, 1000000000) >>> r[45006230] 45016230 4.2.1 Iterators 迭代器. >>> primes = [2, 3, 5, 7] >>> type(primes) <class 'list'> >>> iterator = iter(primes) >>> type(iterator) <class 'list_iterator'> >>> next(iterator) 2 >>> next(iterator) 3 >>> next(iterator) 5 当 next()到序列的最后一个元素之后, 会抛出 StopIteration 异常. 可以通过 try 来 catch 这个异常. >>> next(iterator) 7 >>> next(iterator) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration >>> try: next(iterator) except StopIteration: print('No more values') No more values 每次调用 next(), 迭代器都会维护一个内部状态, 这个状态会记录当前迭代器的位置....
disc3 Q3 hw03 count_dollars Q5.6 hw04 berry_finder 和 max_path_sum hw04 和 lab04 的解析
Conditional Breakpoints, Execution Breakpoints 的设置.
book 看浮点数实现。 浮点数汇编。 lab data lab 继续做以及笔记。 bomb lab phase6和secret bomb。
deivce interrupt 的入口在kernel/trap.c 的 devintr函数. 5.1 Code: Console input ns16550 uart driver 寄存器相关, 每个占 1 个 byte: LSR: RHR: THR: xv6 main 函数通过kernel/console.c中的consoleinit函数来初始化 uart 硬件. 5.4 Timer interrupts RISC-V 的 timer 中断需要在 machine mode 中设置, 而不能在 supervisor mode 中设置.