Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Latest commit

 

History

History
65 lines (34 loc) · 1.16 KB

42-Day2.md

File metadata and controls

65 lines (34 loc) · 1.16 KB

Week2学习总结


Made by 42

Python**语言

  • 数据类型

    • 字符串 strings

    • 列表 lists

    • 字典 dictionary

      • 变量可更改,对象可迭代,类型可更改

      • 默认参数不能设置为可变对象

      • enumerate:返回 list 的指标和元素两部分

        § for idx, val in enumerate(my_list):

        print('idx: {}, value: {}'.format(idx, val))

  • 结构化程序设计

    • for循环
  • 函数 function,类 class

    • 函数:不要为可变参数设置默认值,否则该变量将在多次函数调用中被多次使用

    • help 函数的应用

    • def print_sum(val1, val2):

    • """Function which prints the sum of given arguments."""

    • print('sum: {}'.format(val1 + val2))

    • print(help(print_sum))

  • 模块和包

    • 可以大大节省工作量
  • 文件操作

简单的算法

  • Python的简单代码应用
  • 大数相乘的原始算法和快速算法
  • 插入排序与合并排序的思路
  • 思想:分割问题,降低时间和空间复杂度

算法复杂度分析

  • Recursion Tree

  • 例如,O(n)per level,log(n)+1levels

  • Induction