Kama kila kitabu kina kurasa 400
Then
64x400= 25600.
Irabidi asome kurasa zote hizo.
25700
Nampa task ya kuandika simple calculator.
Iwapo atasoma kila siku masaa 3 je itamchukua muda gani kumaliza vitabu vyote.
Ku complicate kidogo, iwapo week end atapiga masaa 6 je atatumia muda gani kumaliza vitabu vyote.
Write a simple console and gui program to calculate the total tome to complete all books..
Hahaha nakupa mimi hiyo apo codes utampa 🤣🤣🤣
___________________________________
import tkinter as tk
# Function to calculate the total time to read all books
def calculate_reading_time():
pages_per_book = int(pages_per_book_entry.get())
total_books = int(total_books_entry.get())
daily_reading_time = int(daily_reading_time_entry.get())
weekly_reading_time = int(weekly_reading_time_entry.get())
total_pages = pages_per_book * total_books
days_required = total_pages / (daily_reading_time * 3)
weeks_required = total_pages / (weekly_reading_time * 6)
result_label.config(text=f"Reading {total_books} books with {daily_reading_time} hours per day will take {days_required:.2f} days.")
result_label_weeks.config(text=f"Reading {total_books} books with {weekly_reading_time} hours per week will take {weeks_required:.2f} weeks.")
# Create the main window
root = tk.Tk()
root.title("Book Reading Time Calculator")
# Create input labels and entry fields
pages_per_book_label = tk.Label(root, text="Pages per Book:")
pages_per_book_label.pack()
pages_per_book_entry = tk.Entry(root)
pages_per_book_entry.pack()
total_books_label = tk.Label(root, text="Total Books:")
total_books_label.pack()
total_books_entry = tk.Entry(root)
total_books_entry.pack()
daily_reading_time_label = tk.Label(root, text="Daily Reading Time (hours):")
daily_reading_time_label.pack()
daily_reading_time_entry = tk.Entry(root)
daily_reading_time_entry.pack()
weekly_reading_time_label = tk.Label(root, text="Weekly Reading Time (hours):")
weekly_reading_time_label.pack()
weekly_reading_time_entry = tk.Entry(root)
weekly_reading_time_entry.pack()
calculate_button = tk.Button(root, text="Calculate", command=calculate_reading_time)
calculate_button.pack()
# Create result labels
result_label = tk.Label(root, text="")
result_label.pack()
result_label_weeks = tk.Label(root, text="")
result_label_weeks.pack()
# Start the GUI main loop
root.mainloop()
___________________________________