# -*- coding:utf-8 -*-
__author__ = 'Atlantis'
'''现在有10个好玩的小游戏还在持续更新中,敬请期待…'''
import random
'''形状、图案'''
class shape():
#心形
def love(self):
print('编码型:')
print('\n'.join([''.join([('Love'[(x - y) % len('Love')] if ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (
x * 0.05) ** 2 * (
y * 0.1) ** 3 <= 0 else ' ')
for x in range(-30, 30)]) for y in range(30, -30, -1)]))
love = '''veLoveLov veLoveLoveLoveLoveLoveLove eLoveLoveLoveLoveveLoveLoveLoveLoveLoveLoveLoveLoveLoveLovveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveeLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLeLoveLoveLoveLoveLoveLoveLoveLoveLoveoveLoveLoveLoveLoveLoveLoveLoveLoveeLoveLoveLoveLoveLoveLoveLoveLoveveLoveLoveLoveLoveLoveLoveLovoveLoveLoveLoveLoveLoveLoLoveLoveLoveLoveLoveLLoveLoveLoveLovLoveLoveLLovv'''
print('文字型:')
print(love)
return
#锤子
def Mandelbrot(self):
#print('编码型:')
#print('\n'.join([''.join(['*' if abs(
#(lambda a: lambda z, c, n: a(a, z, c, n))(lambda s, z, c, n: z if n == 0 else s(s, z * z + c, c, n - 1))(0,
#0.02 * x + 0.05j * y,
#40)) < 2 else ' '
#for x in range(-80, 20)]) for y in range(-20, 20)]))
hhh = '''*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************'''
print('文字型:')
print(hhh)
return
'''游戏'''
#乘法口诀
def calc():
print('\n'.join([' '.join(['%s*%s=%-2s' % (y, x, x * y) for y in range(1, x + 1)]) for x in range(1, 10)]))
return
#斐波那契数列
def Fibonacci_sequence():
print([x[0] for x in [(a[i][0], a.append([a[i][1], a[i][0] + a[i][1]])) for a in ([[1, 1]],) for i in range(30)]])
return
#猜数字
def guess_my_number(n):
while True:
user_input = input("Enter a positive integer to guess: ")
if len(user_input)==0 or not user_input.isdigit():
print("Not a positive integer!")
else:
user_input = int(user_input)
if user_input > n:
print("Too big! Try again!")
elif user_input < n:
print("Too small! Try again!")
else:
print("You win!")
return True
#彩票
def caipiao():
print('彩票号码:%s' % random.sample(range(1, 50), 6))
return
#算价钱
def price():
def discount(price,rate):
final_price = price * rate
return final_price
old_price = float(input('请输入原价:'))
rate = float(input('请输入折扣率:'))
new_price = discount(old_price,rate)
print('打折后价格是:',new_price)
#猜最爱听的话
def favourite_words():
bingo = '你是帅哥'
answer = input('请输入我最爱听的话:')
while True:
if answer == bingo:
break
answer = input('错了,再输一次:')
print('你是我肚子里的蛔虫吗?')
#猜数字(随机)
def guess_number():
secret = random.randint(1,10)
temp = input("不妨猜一下ironman现在心里想的数字:")
guess = int(temp)
while guess != secret:
temp = input("哎呀,猜错了,请重新输入:")
guess = int(temp)
if guess == secret:
print("你是ironman心里的蛔虫吗?!")
print("哼,猜中了也没有什么奖励!")
else:
if guess > secret:
print("哥,大了,大了")
else:
print("嘿,小了,小了")
print("游戏结束,不玩了^-^!")
#分数评级
def score():
tip = '''评分标椎:100-90分 A级90-80分 B级80-60分 C级60分一下 D级'''
print(tip)
score = int(input('请输入一个分数:'))
if 100 >= score >= 90:
print('A')
if 90 > score >= 80:
print('B')
if 80 > score >= 60:
print('C')
if 60 > score >= 0:
print('D')
if score < 0 or score > 100:
print('输入错误!')
return
'''主程序'''
def main():
Shape = shape()
tips = '''获取游戏编码 请输入 help请输入你想玩的游戏编码:'''
tip = '''一共有10个小游戏:1、变心形 输入12、变锤子 输入23、乘法口诀 输入34、斐波那契数列 输入45、猜数字 输入56、彩票 输入67、算价钱 输入78、最爱听的话 输入89、随机猜数 输入910、分数评级 输入10please try again'''
game = input(tips)
if game == "help":
print(tip)
elif game == "1.1":
Shape.love()
elif game == "1.2":
Shape.Mandelbrot()
elif game == "2.1":
calc()
elif game == "2.2":
Fibonacci_sequence()
elif game == "2.3":
guess_my_number(15)
elif game == "2.4":
caipiao()
elif game == "2.5":
price()
elif game == "2.6":
favourite_words()
elif game == "2.7":
guess_number()
elif game == "2.8":
score()
else:
print('还没更新呢!敬请期待。')
return
if __name__ == '__main__':
main()