Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Can someone change Python cord (task.py) below to Class? You going to use these two classes given: 1. Class Book 2. Class Bookcollection 2.

1. Can someone change Python cord ("task.py") below to Class? You going to use these two classes given: 1. Class Book 2. Class Bookcollection 2. Creating Kivy file 1. App.kv 2. main.py Kevy Output image text in transcribed * Here is CSV file (books.csv) 
 In Search of Lost Time,Marcel Proust,93,c The 360 Degree Leader,John Maxwell,369,c War and Peace,William Shakespeare,999,r Developing the Leader Within You,John Maxwell,225,c The Practice of Computing Using Python,Punch and Enbody,792,c
 task.py 
""" Task 01 """
 from book import Book import csv def main(): global number_books menu = " menu: L - List all books A - Add new book M - Mark a book as complete Q - quit" books = [] in_file = open("books.csv", "r") book_loader = csv.reader(in_file) for book in book_loader: if book[3] == 'r': status = False else: status = True temp = Book(book[0], book[1], int(book[2]), status) books.append(temp) in_file.close() # welcome massage print("Welcome to Reading Tracker 0.1 - by James Yalo") # print("{} books loaded from {}".format(len(book_title, books))) print(menu) selection = input(">>>").upper() while selection != "Q": if selection == "L": list_books(books) # marking books from the list elif selection == "M": unread = 0 for book in books: if not book.is_completed: unread += 1 if unread == 0: print("No required books") else: list_books(books) print("Enter the number of a book to mark as completed") book_handle = 1 finish_read = False while not finish_read: try: number_books = int(input(">>> ")) if number_books  0") elif number_books > len(books): print("Invalid book number") else: finish_read = True except ValueError: # or just except: print("Invalid input; enter a valid number") # check books as marked book_check = books[number_books - book_handle] book_selected = books[number_books - book_handle] book_title = book_selected.title book_author = book_selected.author # mark_completed = 'c' if not book_check.is_completed: book_check.mark_completed() print("{} by {} completed".format(book_title, book_author)) elif book_check.is_completed: print("That book is already completed.") print("{} by {} Marked as completed.".format(book_title, book_author)) print("No book left to read. why not add new book") # adding books here elif selection == "A": adding_book(books) else: print("Invalid menu choice") print(menu) selection = input(">>>").upper() # else: with open("books.csv", "w") as out_file: # Another way of opening files when we # exit the this block the file is automatically saved and closed. for book in books: if book.is_completed: entry = book.title + ',' + book.author + ',' + str(book.number_of_pages) + ',c ' else: entry = book.title + ',' + book.author + ',' + str(book.number_of_pages) + ',r ' out_file.write(entry) # Writing it to the file. print("Have a nice day :)") # going through list print out available books in the list def adding_book(books): global book_pages, book_pages book_title = input("Title:") while book_title == "": print("Input can not be blank") book_title = input("Title:") book_author = input("Author:") while book_author == "": print("Input can not be blank") book_author = input("Author:") if book_pages == "": print("Input can not be blank") book_pages = input("Pages:") print("Just one") finish_read = False while not finish_read: try: book_pages = int(input("Pages:")) while book_pages == "": print("Input can not be blank") book_pages = int(input(book_pages)) finish_read = True except ValueError: print("Invalid input Enter are Correct name") print("{} {} {} is available for adding".format(book_title, book_author, book_pages)) books.append(Book(str(book_title), str(book_author), int(book_pages), False)) # Inserting a new tuple containing the data on new book. def list_books(books): number_pages = 0 number_of_books = 0 for i in range(len(books)): book_title = books[i].title book_author = books[i].author book_pages = int(books[i].number_of_pages) if books[i].is_completed: book_status = 'c' else: book_status = 'r' if book_status == "c": print(" {}. {:40} by {:20} {:3} pages".format(i + 1, book_title, book_author, book_pages)) else: print("*{}. {:40} by {:20} {:3} pages".format(i + 1, book_title, book_author, book_pages)) number_pages += book_pages number_of_books += 1 print("{} books".format(len(books))) if number_of_books: # This is same as saying 'if number_of_books != 0:' # since in python 0 is same as false. I'm showing a way that code may be written. print("You need to read {} pages in {} books".format(number_pages, number_of_books)) else: print( "No books left to read. Why not add a new book?") # If books to read are 0 we print this message instead. main()
GUI Program: Reading Tracker 2.0 Sort by: Pages to read: 462 Author Developing the Leader Within You by John Maxwell, 225 pages (completed) Add New Book... Title The 360 Degree Leader by John Maxwell, 369 pages Author In Search of Lost Time by Marcel Proust, 93 pages Pages: Add Book The Practice of Computing Using Python by Punch and Enbody, 792 pages (completed) Clear You need to read The Practice of Computing Using Python. Get started! GUI Program: Reading Tracker 2.0 Sort by: Pages to read: 462 Author Developing the Leader Within You by John Maxwell, 225 pages (completed) Add New Book... Title The 360 Degree Leader by John Maxwell, 369 pages Author In Search of Lost Time by Marcel Proust, 93 pages Pages: Add Book The Practice of Computing Using Python by Punch and Enbody, 792 pages (completed) Clear You need to read The Practice of Computing Using Python. Get started

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

The number of ways eight cars can line up in a row for a car wash

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago