python 一些练习 (初学)
1 '''temp =input("请输入一个整数:") 2 number = int(temp) 3 4 while number : 5 i = number -1 6 while i : 7 print('',end="") 8 i =i -1 9 j = number 10 while j: 11 print('*',end="") 12 13 j = j - 1 14 print() 15 number = number -1''' 16 17 ############ 18 '''i= 0 19 while i <=100: 20 if i % 2 !=0: 21 print(i,end=" ") 22 i = i+1 23 else: 24 i = i +1''' 25 26 ############ 成绩分类 27 28 '''def fun(x): 29 if x < 60 : 30 print("成绩为:D") 31 elif 60<= x <80: 32 print("成绩为:C") 33 elif 80 <= x < 90: 34 print("成绩为:B") 35 else: 36 print("成绩为:A") 37 38 score = int(input("请输入成绩:")) 39 fun(score)''' 40 41 ################## 第九课 42 # 求水仙花数 43 '''x=1 44 y=0 45 z=0 46 def fun(number): 47 while 100<= number<=999: 48 z=number%10 49 y=(number//10)%10 50 x=number//100 51 if number==x**3+y**3+z**3: 52 print(number,end=" ") 53 number+=1 54 55 56 fun(100)''' 57 58 ############# 输入密码 59 60 '''count = 3 61 password = "nihao" 62 63 while count : 64 passwd = input("请输入密码:") 65 if passwd == password: 66 print("密码正确,进入程序,,,,") 67 break 68 elif "*" in passwd: 69 print("密码中不能含有'*'号!你还有",count,"次机会",end=" ") 70 continue 71 else: 72 print("密码输入有误!你还有",count-1,'次机会!',end=' ') 73 count-=1''' 74 75 ####################### 三色球 76 77 '''print('red\tyellow\tblue') 78 for red in range(0,4): 79 for yellow in range(0,4): 80 for blue in range(2,7): 81 if red + yellow + blue ==8: 82 print(red,'\t',yellow,'\t',blue)''' 83 84 ######################################## 85 86