1. 绘制一个二维随机漫步的图形
直接上代码:
%pylab inline
nsteps = 1000
draws = np.random.randint(-1,2,size=(2,nsteps))
walks = draws.cumsum(1)
plot(walks[0,:],walks[1,:]);
Populating the interactive namespace from numpy and matplotlib
创建向量有许多方法,举例说明:
import numpy as np
print(np.array([2,3,4])) # 可以从列表转换而来,np.array 会尝试为数组推断出一个较为合适的数据类型
[2 3 4]
print(np.zeros( (3,4) , dtype=np.int32)) # zeros 可以创建指定长度或形状的全 0 数组
[[0 0 0 0]
[0 0 0 0]
[0 0 0 0]]
1. 使用循环和向量化两种不同的方法来计算 100 以内的质数之和。
先定义个判断质数的函数。ps:纯手工打造,原生态,哈哈。
def checkprime(x):
if x<=1:
return False;
prime=True;
for i in range(2 , 1+x/2):
if x%i == 0:
prime = False;
break;
return prime;
先来瞎想下,哪些方面能体现人们的生活水平变化?从物质层面上说,吃饱穿暖了,吃肉喝酒不是问题了,开上车了,开上好车了,住上好房子了,超市、商场物品极大丰富,饭店、宾馆、租车店等各种服务应有尽有,遍地开花,从精神层面上说,电视节目五花八门,无所不包,电影作品层出不穷,网上论坛、博客、微博、微信大大促进了人们的信息分享和交流,极大满足了人们的心理需求,图书市场也是好作品不断,所有这些都能体现人们生活水平的提高,还有从人们的脸色和形体动作所体现出来的精神风貌也能体现出人们生活水平的变化。
时间:2006年3月1日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair and David Cameron,气氛很融洽,因为卡梅伦生了个儿子
Mr. David Cameron (Witney) (Con): May I join the Prime Minister in expressing our sympathy for the families of the two British soldiers who died in Iraq yesterday? They died serving our country, and we should honour their memory. I also agree with what the Prime Minister said about Mr. Speaker, and wish him a speedy return.
时间:2007年3月7日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron,George Osborne和David Cameron分别在同性恋和气候大会问题上被调侃。
Mr. David Cameron (Witney) (Con): Last night, the BBC broadcast the Prime Minister’s political obituary; I am sure that it will be the first of many. In it, his senior foreign policy adviser in No. 10 Downing street, Sir Stephen Wall, speaking of his time working with the Prime Minister, said:
“You got the very clear impression...that they could not govern without Gordon but they could not really govern with him either”.
Why would someone at the heart of Downing street say that?
时间:2006年5月17日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron。布莱尔答辩时,坐在卡梅伦旁边的保守党财政事物发言人George Osborne插嘴,结果遭到布莱尔深刻鄙视。
Mr. David Cameron (Witney) (Con): On behalf of the Opposition, may I add our sympathies to what the Prime Minister said about the soldiers who gave their lives in Iraq? Our thoughts should be with their families for what they have done on our behalf.
Two weeks ago the Prime Minister said that automatic deportation would apply to any foreign national
“convicted of an imprisonable offence”.—[ Official Report,3 May 2006; Vol. 445, c. 960.]
Last week he said it would apply to those actually imprisoned. This week the Home Secretary said that automatic deportation would now apply only to foreign nationals serving a “significant” jail term. Which is it?
时间:2006年5月10日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron
Mr. David Cameron (Witney) (Con): I join the Prime Minister in paying tribute to the servicemen and women who died in Iraq. They were serving their country.
Three weeks ago, I asked the Prime Minister about the crisis in children’s hospitals. He said that everything was fine so can he explain why the Minister responsible for hospitals has resigned?
时间:2001年7月18日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:威廉·黑格作为保守党领袖最后一次参加首相质询时间
Mr. William Hague (Richmond, Yorks): Is it still the Prime Minister’s view that the Government’s annual report is a major innovation to be repeated every year?
时间:2003年4月9日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:此时伊拉克战争已接近尾声,布莱尔和保守党领袖邓肯·史密斯的这场对话没有争吵,亮点在于中间有人说出了一个坚决反对伊战的工党党员的名字,惹得哄堂大笑,让布莱尔很是尴尬,沉默无语20秒钟。
Mr. Iain Duncan Smith (Chingford and Woodford Green): In the last three weeks, British and American troops have defeated Iraqi forces and taken Basra, and it now seems that the regime is fast losing its grip on Baghdad. Even as we speak, Iraqi people are celebrating in the streets. This has been one of the most brilliantly executed campaigns of recent history. May I join the Prime Minister in paying heartfelt tribute to the professionalism and bravery of British troops in Iraq, and in remembering those who have given their lives for this country?
I congratulate the Prime Minister on the role that he has played, standing together with our American allies, in liberating the Iraqi people and ousting this evil dictator. He will recall, however, that at the end of the last Gulf war Iraqi generals signed a document of surrender on behalf of the Iraqi regime. The current regime is in complete collapse, it appears, and we all want to prevent further unnecessary loss of life. Given that, from whom do the Prime Minister believe—or from whom do his advisers believe—the coalition can now accept an unconditional surrender?