print("输入3继续循环,输入其他值退出循环。")someInput=input()while someInput=='3': print("感谢你输入3") print("输入3继续循环,输入其他值退出循环。") someInput=input()print("你输入的不是3,退出循环。")
for i in range(1,10,2): print(i)
for cool_guy in ["Spongebob","Spiderman","Justin Timberlake","My Dad"]: print(cool_guy,"is the coolest guy ever!")
num1=float(input("Enter the first number;"))num2=float(input("Enter the second number;"))if num1 < num2: print(num1,"is less than",num2)if num1 > num2: print(num1,"is greater than",num2)if num1 == num2: print(num1,"is equal to",num2)if num1 != num2: print(num1,"is not equal to",num2)
import random,easyguisecret = random.randint(1,99)guess = 0tries = 0easygui.msgbox("it a number between 1 to 99 ,you have 7 times to guess.")while guess != secret and tries < 7 : guess = easygui.integerbox("a number you want :") if not guess : break if guess < secret : easygui.msgbox(str(guess)+"too small,pig") elif guess > secret : easygui.msgbox(str(guess)+"too big,pig") tries = tries + 1if guess == secret: easygui.msgbox("well done,you get it")else : easygui.msgbox("you have no chance,next time to play the game !")
import easyguiflavor=easygui.buttonbox("你喜欢什么口味的冰激凌?",choices=["香草味","巧克力味","草莓味"])easygui.msgbox("你选择了"+flavor) import easyguinum=easygui.integerbox("你想填入什么数字?",title="输入整数",lowerbound=0,upperbound=1000)easygui.msgbox("你填写了"+str(num))
print("i love pizza")print("pizza"*20)print("yum"*40)print("i'm full.")
from urllib.request import urlopenimport sslssl._create_default_https_context = ssl._create_unverified_contextfile = urlopen('heeps://www.huxiu.com/article/323011.html')message = file.read().decode(encoding="utf-8",errors="srrict")print(message)
import randomsecret = random.randint(1,100)guess = 0tries = 0print("a ha,i'm jack,i have a secret!")print("it is a number between 1 to 99,you have six times to guess,come on!")while guess != secret and tries < 6: guess = int(input("a number:")) if guess < secret: print("too small") elif guess > secret: print("too big") tries = tries + 1if guess == secret: print("well done,you got it.")else: print("you have no chance,next time.") print("it is",secret)
ctrl+s保存文件
讲的很好,一学就会,加油!
输入 处理 输出input()输入函数输入字符串
while if elif import 关键词
变量名命名规则1、只能由字母、数字、下划线(_)组成,不能使用其他字符。空格、标点符号和其他字符否是不允许的。2、变量名是区分大小写的。大小写不同,即为两个不同变量。3、变量名必须以字母或下划线开头,不能以数字开头,EG:4fun就不能作为变量名。4、一般(_)用于分割变量中两个单词,例如:first_number=15建议不要在变量名开始或末尾使用下划线,某些情况,在一个标识符的开始he末尾使用下划线字符会有特殊含义,所以要避免这样使用。