首页后端开发Python利用for循环和while循环求n

利用for循环和while循环求n

时间2023-06-03 14:05:02发布访客分类Python浏览474
导读:利用for循环和while循环求n?xStart=raw_input("please enter the int number:" xInt= int(xStart count=0while not xInt==count:count +=...

利用for循环和while循环求n?

xStart=raw_input("please enter the int number:")

xInt= int(xStart)

count=0

while not xInt==count:

count +=1

print count #你输入多少就从1显示到这个数

还有就是求和:

xStart=raw_input("please enter the int number:")

xInt= int(xStart)

count= 0

sum= 0

while not xInt == count:

count += 1

sum += count

print sum

#这里显示的sum是如果你要输入数值5,则显示sum=1+2+3+4+5的值.

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 利用for循环和while循环求n
本文地址: https://pptw.com/jishu/59740.html
python中读取excel文件表格太大怎么解决 dict是线程安全的吗

游客 回复需填写必要信息