a =1
line =int(input("几行等腰三角形:"))
c = line
b = line -1while a <= line :
n =1while n < c :print('~',end ="")
n +=1
c -=1
n =1while n <=2* a -1:print('*',end ="")
n +=1print("")
a +=1
猜词小游戏
import random
chaos_word =''
words =['answer','difficult','python','hello','look','orange']print("\t\t欢迎来到猜词游戏!")
choice =input("是否进行游戏 是/否 :")if choice =='是':
choice_word = random.choice(words)
length_word =len(choice_word)
k = random.sample(choice_word,length_word)for i inrange(length_word):
chaos_word += k[i]print("乱序单词为:"+chaos_word)
word =input("请输入您猜测的英文单词:")if word == choice_word :print("恭喜你猜对了!")else:print("偶~!猜错了,正确答案是:"+choice_word)else:print("\t\t欢迎下次光临!")
exit(0)
求100以内偶数的和
求100以内奇数的和
sum1 =0
sum2 =0for i inrange(1,100,2):
sum1 += i
for j inrange(0,100,2):
sum2 += j
print("一百以内奇数的和为:%s 偶数的和为:%s"%(sum1,sum2))
打印等腰三角形a = 1line = int(input("几行等腰三角形:"))c = lineb = line - 1while a <= line : n = 1 while n < c : print('~',end = "") n += 1 c -= 1 n = 1 while n <= 2 * a - 1 : print('*',end = "") n += 1 print("") a += 1...