Everybody in this country should learn how to program a computer,because it teaches you how to think.
——史蒂夫~乔布斯
圆的面积
import mathradius = 25area = math.pi*radius*radiusprint(area)print("{:.2f}".format(area))
输入
name = input("输入人名:")print("{}".format(name))print("{}".format(name[0]))print("{}".format(name[1:]))
斐波那契
a , b = 1,1while a < 1000 : print(a,end=',') a, b = b,a+bprint("")
同心圆
import turtleturtle.pensize(2)turtle.circle(10)turtle.circle(20)
日期与时间
from datetime import datetimenow = datetime.now()print(now)print(now.strftime("%x"))print(now.strftime("%X"))
习题部分
字符串拼接
str1 = input()str2 = input()print("{} {}".format(str1,str2))
sum(n)
n=input()sum=0for i in range(int(n)+1): sum+=iprint(sum)
9*9
for i in range(1,10): for j in range(1,i+1): print("{}*{}={:2}".format(j,i,j*i),end=' ') print("")
1! + 2! + 3! + ... + n!
n = input()sum = 0tmp = 1for i in range(1,int(n)+1): sum+=tmp tmp*=(i+1)print(sum)
猴子吃桃
ans = 1for i in range(5): ans = (ans + 1)*2print(ans)