Вопрос задан 26.11.2023 в 04:56. Предмет Информатика. Спрашивает Лапшин Александр.

‼️‼️‼️‼️За допомогою модуля Tkinter створіть програму, яка буде аналізувати ціни учня за такими

пунктами: найбільший та найменший бал, середній бал та підраховувати кількість оцінок початкового, середнього, достатнього та високого рівня (у вигляді таблиці)
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Жексен Ердаулет.

Відповідь:

# функція для підрахунку кількості оцінок різного рівня

def count_grades(grades):

   low = 0

   medium = 0

   high = 0

   

   for grade in grades:

       if grade < 4:

           low += 1

       elif grade < 7:

           medium += 1

       else:

           high += 1

   

   return low, medium, high

# головна функція програми

def main():

   # список оцінок учня

   grades = [8, 9, 5, 6, 7, 4, 7, 10, 8, 8]

   

   # знаходимо найбільший, найменший та середній бал

   max_grade = max(grades)

   min_grade = min(grades)

   avg_grade = sum(grades) / len(grades)

   

   # підраховуємо кількість оцінок різного рівня

   low, medium, high = count_grades(grades)

   

   # виводимо результати на екран у вигляді таблиці

   print("Statistics for Student Grades")

   print("------------------------------")

   print(f"Highest Grade: {max_grade}")

   print(f"Lowest Grade: {min_grade}")

   print(f"Average Grade: {avg_grade:.2f}")

   print(f"Low-level Grades (less than 4): {low}")

   print(f"Medium-level Grades (between 4 and 7): {medium}")

   print(f"High-level Grades (greater than 7): {high}")

   

   

if __name__ == '__main__':

   main()

Пояснення:

В цьому коді функція count_grades використовується для підрахунку кількості оцінок різного рівня, яка повертає кортеж з трьох значень - кількість оцінок менше 4 (нижче середнього), кількість оцінок між 4 і 7 (середнього рівня), і кількість оцінок більше 7 (вище середнього).

У головній функції main ми створюємо список оцінок учня, обчислюємо максимальний, мінімальни

Надіюсь добре

0 0
Отвечает Кольцова Татьяна.

import tkinter as tk

class App(tk.Frame):

   def __init__(self, master):

       super().__init__(master)

       self.master = master

       self.master.title("Аналіз цін учня")

       self.grid()

       

       # Додавання елементів віджетів

       tk.Label(self, text="Найбільший бал:").grid(row=0, column=0)

       self.max_grade_entry = tk.Entry(self)

       self.max_grade_entry.grid(row=0, column=1)

       

       tk.Label(self, text="Найменший бал:").grid(row=1, column=0)

       self.min_grade_entry = tk.Entry(self)

       self.min_grade_entry.grid(row=1, column=1)

       

       tk.Label(self, text="Середній бал:").grid(row=2, column=0)

       self.avg_grade_entry = tk.Entry(self)

       self.avg_grade_entry.grid(row=2, column=1)

       

       tk.Label(self, text="Початковий рівень:").grid(row=3, column=0)

       self.beg_grade_entry = tk.Entry(self)

       self.beg_grade_entry.grid(row=3, column=1)

       

       tk.Label(self, text="Середній рівень:").grid(row=4, column=0)

       self.med_grade_entry = tk.Entry(self)

       self.med_grade_entry.grid(row=4, column=1)

       

       tk.Label(self, text="Достатній рівень:").grid(row=5, column=0)

       self.suf_grade_entry = tk.Entry(self)

       self.suf_grade_entry.grid(row=5, column=1)

       

       tk.Label(self, text="Високий рівень:").grid(row=6, column=0)

       self.hig_grade_entry = tk.Entry(self)

       self.hig_grade_entry.grid(row=6, column=1)

       

       self.analyze_button = tk.Button(self, text="Аналізувати", command=self.analyze_grades)

       self.analyze_button.grid(row=7, column=0, columnspan=2)

       

       self.results_label = tk.Label(self, text="")

       self.results_label.grid(row=8, column=0, columnspan=2)

       

   def analyze_grades(self):

       max_grade = self.max_grade_entry.get()

       min_grade = self.min_grade_entry.get()

       avg_grade = self.avg_grade_entry.get()

       beg_grade = self.beg_grade_entry.get()

       med_grade = self.med_grade_entry.get()

       suf_grade = self.suf_grade_entry.get()

       hig_grade = self.hig_grade_entry.get()

       

       # Розрахунок кількості оцінок по рівнях

       beg_count = 0

       med_count = 0

       suf_count = 0

       hig_count = 0

       for grade in [beg_grade, med_grade, suf_grade, hig_grade]:

           if grade:

               grade = int(grade)

               if grade >= 90:

                   hig_count += 1

               elif grade >= 70:

                   suf_count += 1

               elif grade >= 50:

                   med_count += 1

               else:

                   beg_count += 1

       

       # Результати аналізу

        results = f"Найбільший бал: {max_grade}\nНайменший бал: {min_grade}\nСередній бал: {avg_grade}\n\n"

   results += f"Оцінок початкового рівня: {beg_count}\nОцінок середнього рівня: {med_count}\n"

   results += f"Оцінок достатнього рівня: {suf_count}\nОцінок високого рівня: {hig_count}"

   

   self.results_label.config(text=results)

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Creating a Program to Analyze Student Grades using Tkinter

To create a program that analyzes student grades based on various criteria using the Tkinter module, you can follow these steps:

1. Import the necessary modules: - Tkinter: This module provides the necessary tools for creating the graphical user interface (GUI) of the program. - Pandas: This module will be used to handle and analyze the data.

2. Create the GUI: - Use the Tkinter module to create the main window and any other necessary widgets, such as labels, buttons, and tables. - Design the layout of the GUI to display the required information, such as the maximum and minimum grades, average grade, and the count of grades at different levels.

3. Load and analyze the data: - Read the student grades data from a file or any other data source using the Pandas module. - Perform the necessary calculations to determine the maximum and minimum grades, average grade, and the count of grades at different levels (initial, medium, sufficient, and high).

4. Display the results: - Update the GUI widgets with the calculated values to display the maximum and minimum grades, average grade, and the count of grades at different levels in a table format.

Here's an example code snippet that demonstrates how to create a basic program using Tkinter to analyze student grades:

```python import tkinter as tk import pandas as pd

# Function to analyze student grades def analyze_grades(): # Read the student grades data from a file or any other data source # Replace 'grades.csv' with the actual file name or data source df = pd.read_csv('grades.csv')

# Calculate the maximum and minimum grades max_grade = df['Grade'].max() min_grade = df['Grade'].min()

# Calculate the average grade avg_grade = df['Grade'].mean()

# Calculate the count of grades at different levels initial_count = df[df['Grade'] < 60].count()['Grade'] medium_count = df[(df['Grade'] >= 60) & (df['Grade'] < 75)].count()['Grade'] sufficient_count = df[(df['Grade'] >= 75) & (df['Grade'] < 90)].count()['Grade'] high_count = df[df['Grade'] >= 90].count()['Grade']

# Update the GUI widgets with the calculated values max_grade_label.config(text=f"Max Grade: {max_grade}") min_grade_label.config(text=f"Min Grade: {min_grade}") avg_grade_label.config(text=f"Avg Grade: {avg_grade}") grades_table.delete(1.0, tk.END) grades_table.insert(tk.END, f"Initial: {initial_count}\n") grades_table.insert(tk.END, f"Medium: {medium_count}\n") grades_table.insert(tk.END, f"Sufficient: {sufficient_count}\n") grades_table.insert(tk.END, f"High: {high_count}\n")

# Create the main window window = tk.Tk()

# Create labels to display the analyzed results max_grade_label = tk.Label(window) min_grade_label = tk.Label(window) avg_grade_label = tk.Label(window)

# Create a text widget to display the count of grades at different levels grades_table = tk.Text(window, width=20, height=4)

# Create a button to trigger the analysis analyze_button = tk.Button(window, text="Analyze", command=analyze_grades)

# Grid layout for the widgets max_grade_label.grid(row=0, column=0) min_grade_label.grid(row=1, column=0) avg_grade_label.grid(row=2, column=0) grades_table.grid(row=3, column=0) analyze_button.grid(row=4, column=0)

# Start the main event loop window.mainloop() ```

Please note that this is a basic example, and you may need to modify the code to suit your specific requirements. Additionally, you will need to provide the actual data source (e.g., a CSV file) containing the student grades.

Remember to replace `'grades.csv'` in the code with the actual file name or data source that contains the student grades.

I hope this helps you get started with creating a program to analyze student grades using Tkinter! Let me know if you have any further questions.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос