<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 函數應用:學生管理系統 ~~~ # 學生的信息可以使用一個字典類型 # 管理學生可以使用列表 # 定義全局變量學生列表 student_list = [] # list() # print("全局變量:", id(student_list)) # 顯示功能菜單的函數 def show_menu(): print("-----學生管理系統v1.0-----") print("1. 添加學生") print("2. 刪除學生") print("3. 修改學生信息") print("4. 查詢學生信息") print("5. 顯示所有學生信息") print("6. 退出") # 添加學生 def add_student(): name = input("請輸入學生的姓名:") age = input("請輸入學生的年齡:") sex = input("請輸入學生的性別:") # 定義學生字典類型的變量 student_dict = {} # dict() # 把學生的信息使用字典進行存儲 student_dict["name"] = name student_dict["age"] = age student_dict["sex"] = sex # 這里可以不使用global因為列表是可變類型,可以在原有數據的基礎上進行修改,內存地址不變 # 因為列表的內存地址不變,全局變量不需要使用global # 加上global表示內存地址要發生變化 # 把學生信息添加到學生列表中 student_list.append(student_dict) # global student_list # # student_list = [{'name': "李四", "age":"18", "sex":"男"}] # student_list.append(student_dict) # 顯示所有學生信息 def show_all_student(): # print(student_list, id(student_list)) for index, student_dict in enumerate(student_list): # 學號和下標的關系 student_no = index + 1 print("學號:%d 姓名:%s 年齡:%s 性別:%s" % (student_no, student_dict["name"], student_dict["age"], student_dict["sex"])) # 刪除學生信息 def remove_student(): student_no = int(input("請輸入要刪除學生的學號:")) # 獲取學生字典信息的下標 index = student_no - 1 if index >= 0 and index < len(student_list): # 根據下標刪除學生信息 del student_list[index] else: print("請輸入正確的學號") # 修改學生信息 def modify_student(): student_no = int(input("請輸入要修改學生的學號:")) # 根據學號計算下標 index = student_no - 1 if index >= 0 and index < len(student_list): # 根據下標獲取學生字典信息 student_dict = student_list[index] name = input("請輸入您修改后的名字:") age = input("請輸入您修改后的年齡:") sex = input("請輸入您修改后的性別:") student_dict["name"] = name student_dict["age"] = age student_dict["sex"] = sex else: print("請輸入正確的學號") # 查詢學生 def search_student(): name = input("請輸入要查詢的學生姓名:") # 遍歷學生列表信息 for index, student_dict in enumerate(student_list): # pass # 空實現 if student_dict["name"] == name: student_no = index + 1 # 說明找到了這個學生 print("學號:%d 姓名:%s 年齡:%s 性別:%s" % (student_no, student_dict["name"], student_dict["age"], student_dict["sex"])) break else: print("對不起,沒有找到這個學生") # 程序啟動的函數 def run(): while True: # 顯示功能菜單 show_menu() # 接收用戶的指令 menu_option = input("請輸入您需要的功能選項:") if menu_option == "1": print("添加學生") add_student() elif menu_option == "2": print("刪除學生") remove_student() elif menu_option == "3": print("修改學生信息") modify_student() elif menu_option == "4": print("查詢學生信息") search_student() elif menu_option == "5": print("顯示所有學生信息") show_all_student() elif menu_option == "6": print("退出") break # 執行程序啟動的函數 run() ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看