Python之基礎實戰專案

2021-09-27 08:10:11 字數 3796 閱讀 2349

後言我們在之前的學習內容中就可以大概的了解了python的乙個基礎用法。

所以在之前的python【一】,python【二】,python【三】的基礎上我們就對其進行乙個整合。

let`go,**展開。

students =[,

]def

selstu()

:"""

查詢所有

:return:

"""for stu in students:

print

(f"學生的姓名為:,學生的年齡為:"

)def

selstuindex

(index)

:"""

查詢單個

:param index: 當個名字

:return:

"""for stu in students:

if stu[

'name'

]== index:

print

(f"學生的姓名為:,學生的年齡為:"

)def

addstu

(name,age)

:"""

增加乙個學生

:param name: 增加名

:param age: 增加年齡

:return:

"""stu1 =

defeditstu

(index,newname,newage)

:"""

修改學生

:param index: 修改id

:param newname: 修改後名

:param newage: 修改後名

:return:

"""stunew =

students[index]

= stunew

while

true

: a =

input

("請輸入你要進行的操作,\n1,查詢學生\n2,增加學生\n3,修改學生\n4,刪除學生")if

'1'== a:

while

true

: select =

input()

if'1'

== select:

print

("**********==查詢學生**********==="

) selstu(

)elif

'2'== select:

print

("**********==查詢單個學生**********==="

) namesel =

input

("請輸入要查詢的單個學生"

) selstuindex(namesel)

else

:print

("成功返回上一級"

)break

elif

'2'== a:

while

true

: select =

input()

if'1'

== select:

print

("***************===增加學生**********===="

) name1 =

input

("請輸入要增加的學生姓名"

) age1 =

input

("請輸入要增加的學生年齡"

) addstu(name1,age1)

print

("**********==成功增加***************="

)else

:print

("成功返回上一級"

)break

elif

'3'== a:

while

true

: select =

input()

if'1'

== select:

print

("***************===修改學生**********===="

) nameold =

input

("請輸入要修改的學生姓名"

) oldindex =

0 b =

false

for stu in students:

if stu[

'name'

]== nameold:

b =true

oldindex = students.index(stu)

if b:

print

("***************===找到了**********===="

) namenew =

input

("請輸入要修改後的學生姓名:"

) agenew =

input

("請輸入要修改後的學生年齡:"

) editstu(oldindex,namenew,agenew)

print

("**********==成功增加***************="

)else

:print

("***************===沒有找到你輸入的學生資訊**********===="

)else

:print

("成功返回上一級"

)break

elif

'4'== a:

while

true

: select =

input()

if'1'

== select:

print

("***************===刪除學生**********===="

) namedel =

input

("請輸入要刪除的學生姓名"

) delindex =

0 b =

false

for stu in students:

if stu[

'name'

]== namedel:

b =true

delindex = students.index(stu)

if b:

print

("***************===找到了**********===="

) students.pop(delindex)

print

("**********==成功刪除***************="

)else

:print

("***************===沒有找到你輸入的學生資訊**********===="

)else

:print

("成功返回上一級"

)break

else

:print

("關閉了,拜拜"

)break

此專案copy即可用,額,差不多的知識點都用到了ヽ(ー_ー)ノ

Python專案實戰

匯入pygame模組 import time import pygame from pygame.constants import def main 完成整個程式的控制函式 1.建立乙個視窗 screen pygame.display.set mode 1200 700 0,32 2.建立乙個,當作...

python基礎實戰之猜年齡遊戲

目錄age 18 inp age input 請輸入年齡 strip if inp age.isdigit inp age int inp age if age inp age print 猜小了 elif age inp age print 猜大了 else print 猜對了 else prin...

Python基礎程式設計實戰

python語言起源於1989年,並在1991年正式公開發行。其簡單性 物件導向 可擴充套件性 跨平台性等特徵深受人們所喜愛。隨著人工智慧時代的到來,python語言的發展可謂一日千里,已經一躍成為人工智慧時代的 第一語言 本認證簡單介紹了python語言的特性 發展現狀,並且在最後配合兩個實用的案...