python循环输入若干成绩_Python输入与循环

  • Post author:
  • Post category:python


python

while循环

while 语句:

执行语句

结束条件

#应用while输出1到11

counts = 1

while True:

print(“counts:”, counts)

counts = counts +1 #counts +=1

if counts == 11:

break

for 循环

for 变量 in range(起始值,终止值,步长):

循环语句

#从零开始以3为步长不超过10

for i in range(0,10,3)

print(i)

python注释中获得输入信息的几种方式

方法1:

变量1 = input(“A”)

变量2 = input(“B”)

info = ”’

C:%s

D:%s

”’%(变量1,变量2)

#输入姓名、年龄,输出姓名、年龄

name = input(“name”)

age = int(input(“age”))

info = ”’

————-info of %s———

name:%s

age:%d

”’%(name,name,age)

pr



版权声明:本文为weixin_34722015原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。