銆怭ython鍒烽绡囥€戔€斺€擯ython鍏ラ棬 06 鏉′欢璇彞

fpga开发

🤵鈥嶁檪锔?涓汉涓婚〉: @鍖楁瀬鐨勪笁鍝?涓汉涓婚〉

👨鈥?#x1f4bb; 浣滆€呯畝浠?#xff1a;Python棰嗗煙鏂版槦鍒涗綔鑰呫€?br />
📒 绯诲垪涓撴爮:銆?a href=”https://blog.csdn.net/m0_68744965/category_11957439.html?spm=1001.2014.3001.5482″>鐗涘棰樺簱-Python绡?/a>銆?br />
🌐鎺ㄨ崘銆?a href=”https://www.nowcoder.com/link/pc_csdncpt_flyme_python”>鐗涘缃?/a>銆嬧€斺€?code>鎵惧伐浣滅鍣?/code>|绗旇瘯棰樺簱|闈㈣瘯缁忛獙|瀹炰範缁忛獙鍐呮帹姹傝亴灏变笟涓€绔欒В鍐?/code>

👉 鐐瑰嚮閾炬帴杩涜娉ㄥ唽瀛︿範

接口文档


鐗涘棰樺簱銆?a href="https://www.nowcoder.com/link/pc_csdncpt_flyme_python">鍦ㄧ嚎缂栫▼-Python绡?/a>銆?/h1>

鈥冣€?code>python鐨勫涔犺繕鏄緱鍩虹鐭ヨ瘑+鑷繁鍔ㄦ墜鍚屾杩涜銆傚鏋滄槸python鏂版墜,闇€瑕佹壘涓€涓彲浠ュ湪绾跨粌涔犲緱缃戠珯,鎴戝缓璁綘鍘?a href=”https://www.nowcoder.com/link/pc_csdncpt_flyme_python”>鐗涘缃?/a>澶氱粌涔犮€?/p>


Python鍏ラ棬:06 鏉′欢璇彞 NP43 – NP48

报错

NP43 鍒ゆ柇甯冨皵鍊?/a>

鎻忚堪
Python鐨勬潯浠惰鍙ヤ緷闈犲皢杩愮畻缁撴灉杞彉鎴愬竷灏斿€煎悗杩涜鍒ゆ柇,鐒跺悗鍒嗘敮,濡傛灉鎴戜滑鐩存帴鍒ゆ柇甯冨皵鍊间細鎬庝箞鏍峰憿?杈撳叆甯冨皵鍙橀噺,浣跨敤鏉′欢璇彞鍒ゆ柇,濡傛灉涓虹湡鍒欒緭鍑?#34;Hello World!鈥?#xff0c;鍚﹀垯杈撳嚭"Erros!鈥濄€?/p>

杈撳叆鎻忚堪:
杈撳叆0 鎴栬€?1銆?/p>

杈撳嚭鎻忚堪:
杈撳嚭"Hello World!鈥滄垨鑰?#34;Erros!鈥濄€?/p>

绀轰緥1
杈撳叆:1
杈撳嚭:Hello World!

eNSP

浠g爜:

去中心化

x = int(input())
if x == 1:
    print("Hello World!")
else:
    print("Erros!")

NP44 鍒ゆ柇鍒楄〃鏄惁涓虹┖

鎻忚堪
鍒涘缓涓€涓┖鍒楄〃my_list,濡傛灉鍒楄〃涓虹┖,璇蜂娇鐢?code>print()璇彞涓€琛岃緭鍑哄瓧绗︿覆'my_list is empty!',鍚﹀垯浣跨敤print()璇彞涓€琛岃緭鍑哄瓧绗︿覆'my_list is not empty!'銆?/p>

杈撳叆鎻忚堪:
鏃?/p>

杈撳嚭鎻忚堪:
鎸夐鐩弿杩拌繘琛岃緭鍑哄嵆鍙€?/p>

浠g爜:

IO流

my_list = []
if len(my_list) == 0:
    print('my_list is empty!')
else:
    print('my_list is not empty!')
    

NP45 绂佹閲嶅娉ㄥ唽

鎻忚堪
鍒涘缓涓€涓緷娆″寘鍚瓧绗︿覆'Niuniu'銆?#39;Niumei'銆?#39;GURR'鍜?code>'LOLO'鐨勫垪琛?code>current_users,鍐嶅垱寤轰竴涓緷娆″寘鍚瓧绗︿覆'GurR'銆?#39;Niu Ke Le'銆?#39;LoLo'鍜?code>'Tuo Rui Chi鈥欑殑鍒楄〃new_users,浣跨敤for寰幆閬嶅巻new_users,濡傛灉閬嶅巻鍒扮殑鏂扮敤鎴峰悕鍦?code>current_users涓?#xff0c;鍒欎娇鐢?code>print()璇彞涓€琛岃緭鍑虹被浼煎瓧绗︿覆'The user name GurR has already been registered! Please change it and try again!'鐨勮鍙?#xff0c;鍚﹀垯浣跨敤print()璇彞涓€琛岃緭鍑虹被浼煎瓧绗︿覆'Congratulations, the user name Niu Ke Le is available!'鐨勮鍙ャ€?#xff08;娉?#xff1a;鐢ㄦ埛鍚嶇殑姣旇緝涓嶅尯鍒嗗ぇ灏忓啓)

Java反射机制

杈撳叆鎻忚堪:
鏃?/p>

杈撳嚭鎻忚堪:
鎸夐鐩弿杩拌繘琛岃緭鍑哄嵆鍙€?/p>

The user name GurR has already been registered! Please change it and try again!
Congratulations, the user name Niu Ke Le is available!
The user name LoLo has already been registered! Please change it and try again!
Congratulations, the user name Tuo Rui Chi is available!

浠g爜:

思想

#涓轰簡涓嶅尯鍒嗗ぇ灏忓啓鎶婂垽鏂殑閮借浆鎴愬ぇ鍐?/span>
current_users=[i.upper() for i in ['Niuniu','Niumei','GURR','LOLO']]

#鍥犱负杈撳嚭鐨勫瓧绗︿覆瑕佷繚鎸佸師鏉ョ殑鏍峰瓙,杩欎釜鍒楄〃鍐呭涓嶈兘鏀?/span>
new_users=['GurR','Niu Ke Le','LoLo','Tuo Rui Chi']
for i in new_users:
    # 閫氳繃upper()鏉ヨ皟鏁村ぇ鍐欏悗鍐嶅垽鏂?/span>
    if i.upper() in current_users:  
        print(f"The user name {i} has already been registered! Please change it and try again!")
    else:
        print(f"Congratulations, the user name {i} is available!")

NP46 鑿滃搧鐨勪环鏍?/a>

鎻忚堪
鐗涘椋熷爞浠婂ぉ鍑嗗浜嗗緢澶氫赴鐩涚殑鍗堥, 'pizza'10鍧楅挶涓€浠?#xff0c;'rice'2鍧楅挶涓€浠?#xff0c;'yogurt'5鍧楅挶涓€浠?#xff0c;鍓╀笅鐨勫叾浠栬彍鍝侀兘鏄?code>8鍧楅挶涓€浠姐€傜墰鐗涘湪鏌愮獥鍙g偣椁?#xff0c;璇蜂綘鏍规嵁浠栬緭鍏ョ殑瀛楃涓?#xff0c;浣跨敤if-elif-else璇彞鍒ゆ柇鐗涚墰闇€瑕佽姳璐瑰灏戦挶?

tomcat

杈撳叆鎻忚堪:
杈撳叆涓€涓瓧绗︿覆琛ㄧず鑿滃搧銆?/p>

杈撳嚭鎻忚堪:
杈撳嚭璇ヨ彍鍝佺殑浠锋牸銆?/p>

绀轰緥1
杈撳叆:pizza
杈撳嚭:10

selenium

浠g爜:

java8

s = input()
if s == 'pizza':
    print(10)
elif s == 'rice':
    print(2)
elif s == 'yogurt':
    print(5)
else:
    print(8)

NP47 鐗涚墰鐨勭哗鐐?/a>

鎻忚堪
鐗涚墰鍦ㄩ棬澶存矡澶у瀛︿範,涓€瀛﹀勾杩囧幓浜?#xff0c;闇€瑕佹牴鎹粬鐨勬垚缁╄绠椾粬鐨勫钩鍧囩哗鐐?#xff0c;鍋囧缁╃偣涓庣瓑绾х殑瀵瑰簲鍏崇郴濡備笅琛ㄦ墍绀恒€傝鏍规嵁杈撳叆鐨勭瓑绾у拰瀛﹀垎鏁?#xff0c;璁$畻鐗涚墰鐨勫潎缁?#xff08;姣忛棬璇惧鍒嗕箻涓婂崟闂ㄨ缁╃偣,姹傚拰鍚庡瀛﹀垎姹傚潎鍊?#xff09;銆?/p>

A
4.0
B
3.0
C
2.0
D
1.0
F
0

杈撳叆鎻忚堪:
杩炵画杈撳叆涓€琛岀瓑绾т竴琛屽鍒?#xff0c;閬囧埌绛夌骇涓篎alse鍒欑粨鏉熻緭鍏ャ€?/p>

杈撳嚭鎻忚堪:
鍧囩哗淇濈暀涓や綅灏忔暟銆?/p>

浠g爜:

android版本适配

d = {'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0}

s = 0
c = 0
while True:
    grade = input()
    if grade == "False":
        break
    credit = int(input())
    c += credit
    s += d.get(grade)*credit

    
print('{:.2f}'.format(s/c))
      

NP48 楠岃瘉鐧诲綍鍚嶄笌瀵嗙爜

鎻忚堪
鐗涘缃戠殑鐧诲綍绯荤粺闇€瑕侀獙璇佺敤鎴峰悕涓庡瘑鐮?#xff0c;褰撲簩鑰呴兘姝g‘鏃舵墠鍏佽鐧诲綍,鍏朵腑绠$悊鍛樼殑鐢ㄦ埛鍚嶄负'admis',瀵嗙爜涓?code>'Nowcoder666'銆傝浣犱娇鐢?code>if-else璇彞,鏍规嵁杈撳叆鐨勭敤鎴峰悕ID鍜屽瘑鐮?#xff0c;鍒ゆ柇璇ョ敤鎴风瓑鍚︾櫥褰曘€?/p>

杈撳叆鎻忚堪:
绗竴琛岃緭鍏ュ瓧绗︿覆琛ㄧず鐢ㄦ埛鍚?#xff1b;
绗簩琛岃緭鍏ュ瓧绗︿覆琛ㄧず瀵嗙爜銆?/p>

杈撳嚭鎻忚堪:
鐧诲綍鎴愬姛杈撳嚭"Welcome!",鐧诲綍澶辫触杈撳嚭"user id or password is not correct!"

AndroidStudio

绀轰緥1
杈撳叆:admis
鈥冣€冣€?code>Nowcoder666
杈撳嚭:Welcome!

小程序登陆

浠g爜:

数模学习

id = input()
password = input()
if id == 'admis' and password == 'Nowcoder666':
    print('Welcome!')
else:
    print("user id or password is not correct!")

鑷祴杩愯:

mysql面试题

淇濆瓨鎻愪氦:

文件描述符


鎺?鑽?鐗涘棰橀湼-缁忓吀楂橀闈㈣瘯棰樺簱

🌐 鎵惧伐浣滅鍣?|绗旇瘯棰樺簱|闈㈣瘯缁忛獙|澶у巶闈㈣瘯棰?/code> 👉 鐐瑰嚮閾炬帴杩涜娉ㄥ唽瀛︿範

注册中心


发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注