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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python编程面试题

發布時間:2025/3/20 python 9 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python编程面试题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 實現需求為 注冊、登錄、查看昵稱的功能

def userN():username = input("請輸入賬號: \n")password = input('請輸入密碼: \n')return username,passworddef register():# 注冊函數封裝username,password= userN()temp = username + "|" + passwordwith open('D:\Test_Python\login.md','w') as file:file.write(temp)def login():# 登錄函數封裝username,password= userN()with open('D:\Test_Python\login.md') as file:user = file.read().split("|")if username == user[0] and password == user[1]:return '登錄成功'else:return '登錄失敗,請檢查賬號或者密碼'def getNick(func):# 查看個人主頁with open('D:\Test_Python\login.md') as file:user = file.read().split("|")if func:print('{}您好,歡迎再次回來!'.format(user[0]))else:print('您為進行登錄,請登錄!')def exit():# 退出系統import sysprint('系統已退出,歡迎下次再登錄!')sys.exit(1)def Main():while True:put = int(input('請選擇 1.注冊 2.登錄 3.退出系統'))if put == 1:register()elif put == 2:getNick(login())elif put == 3:exit()else:print('輸入錯誤,請重新輸入...')continueif __name__ == '__main__':Main()

2. 列表a = [1,2,3,4,5,6,7],將列表a的值賦給列表b,在不影響列表a的情況下,將列表b的值每間隔一個元素替換成6

''' 遇到問題沒人解答?小編創建了一個Python學習交流QQ群:531509025 尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書! '''import copya = [1,2,3,4,5,6,7]b = a[:]items = len(b)for i in range(1,items):# print(i)if i%2==0:# print(i)b[i] = 6print(a)print(b)[1, 2, 3, 4, 5, 6, 7][1, 2, 6, 4, 6, 6, 6]

3.讓用戶輸入用戶密碼,成功打印歡迎信息,輸錯提示還剩幾次機會,三次機會仍然錯誤退出程序

times = 3while times>0:user = input('請輸入用戶名:')pwd = input('請輸入密碼:')if user =='admin' and pwd =='admin':print('歡迎進入KZ系統')if times != 0:print('您還剩'+str(times-1)+'次機會')else:passelse:if user == 'Admin' and pwd == '':print('密碼錯誤')if times != 0:print('您還剩'+str(times-1)+'次機會')else:passelse:print('輸入有誤')if times != 0:print('您還剩'+str(times-1)+'次機會')# continueelse:breaktimes -= 1

總結

以上是生活随笔為你收集整理的python编程面试题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。