猜数字游戏

#猜数字游戏,可重复玩
import random
def conjecture(): #猜数字游戏的函数
    answer = random.randint(1, 100)  #产生的随机数范围包括下限和上限
    print(answer)
    counter = 0
    print('请猜一猜这个整数(1—100)是多少?')
    while True:
        counter += 1
        number = int(input('请输入:'))
        if number < answer:
            print('大一点')
        elif number > answer:
            print('小一点')
        else:
            print('恭喜你,猜对了!')
            print('你总共猜了%d次' % counter)
            if counter > 7:
                print('你的智商余额明显不足')
            break
    return counter

while True: #可重复玩
    conjecture()
    again = input('再玩一次?(yes/no)')
    if again == 'yes':
        continue
    else:
        break
#左上三角乘法表
for i in range(1, 10):
    for j in range(1, 10-i+1):
        print(' {}x {}= {}'.format(i, j, j*i), end='\t')
    print('\n')

#左下三角乘法表
for i in range(1, 10):
    for j in range(1, i+1):
        print(' {}x {}= {}'.format(i, j, i*j), end='\t')
    print('\n')

#右上三角乘法表
for i in range(1, 10):
    for k in range(1, i):
        print(end='\t\t')
    for j in range(i, 10):
        print(' {}x {}= {}'.format(i, j, j*i), end='\t')
    print('\n')

#右下三角乘法表
for i in range(1, 10):
    for k in range(1, 10-i):
        print(end='\t\t')
    for j in range(10-i, 10):
        print(' {}x {}= {}'.format(i, j+1, (j+1)*i), end='\t')
    print('\n')