在博主的第一篇博文中,博主创建了一个模拟点书系统。现在博主对模拟点书系统进行第一次改进。
改进要点:1,对程序的结构进行优化,加入了函数知识。
2,对添加了一些问候语,让模拟程度更迷真
涉及的知识:Python中的函数
代码:
def punctuate_books(your_books): active=True while active: temp=input("Plese choose your books: ") your_books.append(temp) choose=input("Do you want to contnue choose some books?(yes/no) ") if choose=="no": print("Those are your punctuate books : ") for books in your_books: print(books) print("\n Thank you for coming our bookstore") active=False our_books=["<<c++>>","<<Java>>","<<C>>","<<PHP>>","<<c#>>","<<Python>>","<<F#>>"] print("Welcome to our bookstore ,there are our books:\n") for our_book in our_books: print(our_book) Your_books=[] punctuate_books(Your_books)