日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

Python练习-2

發(fā)布時(shí)間:2024/3/7 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python练习-2 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#1、使用while循環(huán)輸入 1 2 3 4 5 6 8 9 10 count = 0 while count < 10:count += 1 # count = count + 1if count == 7:print(' ')else:print(count) count = 0 while count < 10:count += 1 # count = count + 1if count == 7:continueprint(count) #3、輸出 1-100 內(nèi)的所有奇數(shù) #方法一: count = 1 while count < 101:print(count)count += 2 #方法二: count = 1 while count < 101:if count % 2 == 1:print(count)count += 1

  

#5、求1-2+3-4+5 ... 99的所有數(shù)的和 sum = 0 count = 1 while count < 100:if count % 2 == 0:sum = sum - countelse:sum = sum + countcount += 1 print(sum)

?

#6、用戶登陸(三次機(jī)會(huì)重試) #input 心中有賬號,密碼 while i = 0 while i < 3:username = input('請輸入賬號:')password = int(input('請輸入密碼:'))if username == '咸魚哥' and password == 123:print('登錄成功')else:print('登錄失敗請重新登錄')i += 1

?

#格式化輸出 # % s d # name = input('請輸入姓名') # age = input('請輸入年齡') # height = input('請輸入身高') # msg = "我叫%s,今年%s 身高 %s" %(name,age,height) # print(msg) """ name = input('請輸入姓名:') age = input('請輸入年齡:') job = input('請輸入工作:') hobbie = input('你的愛好:')msg = '''------------ info of %s ----------- Name : %s Age : %d job : %s Hobbie: %s ------------- end -----------------''' %(name,name,int(age),job,hobbie) print(msg) """ name = input('請輸入姓名') age = input('請輸入年齡') height = input('請輸入身高') msg = "我叫%s,今年%s 身高 %s 學(xué)習(xí)進(jìn)度為3%%s" %(name,age,height) # %%轉(zhuǎn)譯% print(msg)

?

count = 0 while count <= 5 :count += 1if count == 3:breakprint("Loop",count)else:print("循環(huán)正常執(zhí)行完啦") print("-----out of while loop ------")

?

轉(zhuǎn)載于:https://www.cnblogs.com/LXL616/p/10622310.html

總結(jié)

以上是生活随笔為你收集整理的Python练习-2的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。