# wygenorowano za pomocą chata-gpt-3 import matplotlib.pyplot as plt def count_words_starting_with(text): counts = {} # słownik do przechowywania ilości wyrazów dla każdej litery words = text.split() # podziel tekst na wyrazy for word in words: if word[0].isalpha(): # sprawdź, czy pierwszy znak jest literą first_letter = word[0].lower() # przekształć na małą literę counts[first_letter] = counts.get(first_letter, 0) + 1 # zwiększ licznik dla danej litery return counts def plot_bar_chart(counts): letters = sorted(counts.keys()) # posortuj litery alfabetycznie values = [counts[letter] for letter in letters] # pobierz ilości wyrazów dla poszczególnych liter plt.bar(letters, values) plt.xlabel('Litera') plt.ylabel('Ilość wyrazów') plt.title('Ilość wyrazów zaczynających się na poszczególne litery alfabetu') plt.show() if __name__ == "__main__": text = "Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive." word_counts = count_words_starting_with(text) plot_bar_chart(word_counts) # nie wiem jak mogę skorzystać z kodu w C(_rvmain), chyba to jeden sposób jak stworzyć wykres