''' Welcome to LearnPython.NET File Name: PDataType.py Download from:https://www.learnpython.net/cn/python-code-samples.html Author: LearnPython.Net Editor: CoderChiu ''' #定义两个整数nA和nB nA = 10 nB = 20 print("nA(10) + nB(20) = ", nA + nB) print("nA(10) - nB(20) = ", nA - nB) print("nA(10) * nB(20) = ", nA * nB) print("nA(10) / nB(20) = ", nA / nB) print("nA(10) ** nB(20) = ", nA ** nB) print("nA(10) // nB(20) = ", nA // nB) #3个小朋友抓的螃蟹数量 nLukasCrabNum = 5 nRobinCrabNum = 7 nAlexCreabNum = 4 if nLukasCrabNum > nRobinCrabNum : print("Lukas is great!") elif nLukasCrabNum == nRobinCrabNum: print("Lukas and Robin is great!") else: print("Robin is great!") #Lukas 和 Robin都捉到5只螃蟹,就去吃饭; if (nLukasCrabNum >= 5) and (nRobinCrabNum >= 5): print("Go to eat something.") else: print("Searing crabs.") #Alex 和 Robin都捉到5只螃蟹,就去吃饭; if (nAlexCreabNum >= 5) or (nRobinCrabNum >= 5): print("Go to eat something.") else: print("Searing crabs.") #捉到5只螃蟹的,就去吃饭;没有捉到的,就继续; bLukas = nLukasCrabNum >= 5 bRobin = nRobinCrabNum >= 5 bAlex = nAlexCreabNum >= 5 #7点钟,还没有吃饭的,就要去吃饭; if not bLukas: print("Lukas go to eat something after 7.") if not bRobin: print("Robin go to eat something after 7.") if not bAlex: print("Alex go to eat something after 7.")