python 3 条件判断


条件判断:

if 语句
python 3 条件判断
if else 语句
python 3 条件判断

 

 python 3 条件判断
python 3 条件判断

 

 

 

循环:

 python 3 条件判断

python 3 条件判断

 

 range(5)是生成小于5的0,1,2,3,4,如果加上一个list[range(5)] 就是生成一个列表[0,1,2,3,4]
如果计算0-100的整数的相加和:  
sum = 0  
for i in range(101):
    sum = sum+i
  print(sum)

第二种是while循环,只要条件满足就一直循环,条件不满足退出循环。

(这里计算100以内的所有奇数的和)
sum = 0
n = 99
while n > 0:
  sum = sum+n
  n = n-2
print(sum)

TRANSLATE with x

English

Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  

python 3 条件判断


 

TRANSLATE with

COPY THE URL BELOW

Back

EMBED THE SNIPPET BELOW IN YOUR SITE

Enable collaborative features and customize widget: Bing Webmaster Portal
Back

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281943.html

(0)
上一篇 2022年8月24日
下一篇 2022年8月24日

相关推荐

发表回复

登录后才能评论