• Предмет: Информатика
  • Автор: tarasenkopolina08
  • Вопрос задан 4 месяца назад

Створити програму, яка по клацанню на кнопці виводить інформацію про одну з планет Сонячної системи. Надо сделать в ПАЙТОНЕ

Ответы

Ответ дал: dimonchop
2

Відповідь:

import tkinter as tk

# Define planet information

planet_info = {

   "Mars": "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, after Mercury. It is often referred to as the Red Planet because of its reddish appearance.",

}

# Define function to show planet information

def show_info(planet):

   info_label.configure(text=planet_info[planet])

# Create main window

root = tk.Tk()

root.title("Information about planets")

root.geometry("300x200")

# Create button for Mars

mars_button = tk.Button(root, text="Mars", command=lambda: show_info("Mars"))

mars_button.pack(pady=10)

# Create label for displaying information

info_label = tk.Label(root, text="", font=("Helvetica", 12))

info_label.pack(pady=20)

# Run main loop

root.mainloop()

Вас заинтересует