JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

7 - for循环while循环 1+2+...+100和

发布时间 2024-01-13 16:47:30作者: ljh-

'''
计算1+2+3+4+....+100的和? (while循环)
'''
u = 1
sum = 0
while u<=100:
sum = sum + u
u = u + 1
print(sum)

计算1+2+3+4+....+100的和?(for循环)

v = 1
sum = 0
for i in range(1,101):
sum = sum + v
v = v + 1
print(sum)

    本栏目推荐文章
  • 微信小程序 取列表的for循环的第一个值
  • SHARPNESS-AWARE MINIMIZATION FOR EFFICIENTLY IMPROVING GENERALIZATION论文阅读笔记
  • 7 - for循环while循环 1+2+...+100和
  • 8- for循环与range()
  • 如何让Visual Studio Tools for Unity插件用于调试你自己的Mono嵌入应用程序
  • 5- while循环
  • 6- for循环
  • 《RAPL: A Relation-Aware Prototype Learning Approach for Few-Shot Document-Level Relation Extraction》阅读笔记
  • An improved LSTM-based model for identifying high working intensity load segments of the tractor load spectrum
  • D25XB100-ASEMI家用电器整流桥D25XB100
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们