Python 2
实例一:
print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n")
#输入一个数
number = int(input("请输入您认为符合条件的数:"))
#判断是否符合条件
if number%3 == 2 and number%5 == 3 and number%7 == 2:
print(number,"符合条件:三三数之剩二,五五数之剩三,七七数之剩二")
实例二:
print("今有物不知何数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n")
number = int(input("请输入瑛姑给出的数:"))
if number%3 == 2 and number%5 == 3 and number%7 == 2:
print(number,"符合条件")
else:
print(number,"不符合条件")
实例三:
print("在古希腊神话中,玫瑰集爱情与美丽于一身,所以人民常用玫瑰来表达爱情。")
print("但是不同朵数的玫瑰花代表的含义是不同的.\n")
#获取用户输入的朵数,并转换为整形
number = int(input("输入您想送几朵玫瑰花,何丁锋会告诉您含义:"))
if number == 1:
#如果等于1则输出提示信息
print("1朵:你是我的唯一!")
elif number == 3:
print("3朵:I LOVE YOU!")
elif number == 10:
print("10朵:十全十美!")
elif number == 99:
print("99朵:天长地久!")
elif number == 108:
print("108朵:求婚!")
else:
print("何丁锋也不知道了!可以考虑送1朵,3朵,10朵,99朵或100朵哟!")
实例四:
print("\n为了您和其他人的安全,严禁酒后开车!\n")
proof = int(input("请输入每100毫升血液的酒精含量:"))
if proof < 20:
print("\n您还不构成饮酒行为,可以开车,但要注意安全!")
else:
if proof < 80:
print("\n已经达到酒后驾驶标准,请不要开车!")
else:
print("\n已经达到醉酒驾驶标准,千万不要开车!")
实例五:
print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n")
none = True
number = 0
while none:
number += 1
if number%3 == 2 and number%5 == 3 and number%7 == 2:
print("答曰:这个数是",number)
none = False
实例六:
print("今有物不知何数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n")
for number in range(100):
if number%3 == 2 and number%5 == 3 and number%7 == 2:
print("答曰:这个数是",number)
实例七:
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
============= RESTART: D:/LLLLllloooooo/芝士左叶/PythonZYtwo/Shili7.py =============
1x1=1
1x2=2 2x2=4
1x3=3 2x3=6 3x3=9
1x4=4 2x4=8 3x4=12 4x4=16
1x5=5 2x5=10 3x5=15 4x5=20 5x5=25
1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36
1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49
1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64
1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81
实例八:
print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n")
for number in range(100):
if number%3 == 2 and number%5 == 3 and number%7 == 2:
print("答曰: 这个数是",number)
break
实例九:
total = 99
for number in range(1,100):
if number % 7 ==0:
continue
else:
string = str(number)
if string.endswith('7'):
continue
total -= 1
print("从1数到99共拍腿",total,"次。")