MIT 6.0001
松鼠爆米花
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
extend和append区别
a = ['dog', 'cat']b = ['cat']a.append(b)# ['dog', 'cat', ['snake']]a.extend(b)# ['dog', 'cat', ['snake'], 'snake']append是将b看作一个object相加extend 是list中的元素相加原创 2020-03-12 15:22:23 · 162 阅读 · 0 评论 -
return和print的区别
第四课的课堂练习中有一个小例子:def add(x, y): return x+y def mult(x, y): print (x * y)add(1, 2)print(add(1, 2))mult(3, 4)print(mult(3, 4))题目问的是屏幕上会输出几行结果?显然,应该是4行.前三行为数值,最后一行是None.mult这个函数返回None,没有re...原创 2020-03-11 22:20:23 · 810 阅读 · 0 评论 -
MIT 6.0001 ps2
# Problem Set 2, hangman.py# Name: # Collaborators:# Time spent:# Hangman Game# -----------------------------------# Helper code# You don't need to understand this helper code,# but you will...原创 2020-03-11 21:56:52 · 648 阅读 · 0 评论 -
MIT 6.0001 ps1 c
bisection search有递归,无递归两种写法def achieve_down_payment(num, annual_salary, portion_down_payment): current_savings = 0 month =1 while ((current_savings - portion_down_payment) < (-100)):...原创 2020-03-06 21:07:15 · 417 阅读 · 0 评论 -
MIT 6.0001 ps1 b
import mathannual_salary = int(input('Enter your annual salary:'))portion_salary = float(input('Enter the percent of your salary to save, as a decimal:'))total_cost = int(input('Enter the cost of y...原创 2020-03-06 17:12:28 · 285 阅读 · 0 评论 -
MIT 6.0001 ps1 a
# House Hunting# total_cost: the cost of your dream home# portion_down_payment: 预付款 assume 0.25# current_savings: start with 0# r: annual return of investment current_savings*r/12# annual_salar...原创 2020-03-06 16:20:44 · 258 阅读 · 0 评论 -
MIT 6.0001 ps0
Assignment:Write a program that does the following in order:Asks the user to enter a number “x”Asks the user to enter a number “y”Prints out number “x”, raised to the power “y”.Prints out the lo...原创 2020-03-04 14:28:44 · 226 阅读 · 0 评论
分享