כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-VS Code. ההתקדמות נשמרת.Write in each exercise's editor, press Run to see output and Check for the automatic checker. You can also work in VS Code. Progress is saved.
חימום: 3 שאלותWarm-up: 3 questions
תרגיליםExercises
תרגילExercise 1
הצצה בנתוניםA first look
קראו את הנתונים לתוך df והדפיסו: מספר השורות, את הכותרת של הספר הארוך ביותר (idxmax), ואת ממוצע הדירוג מעוגל ל-2.
Read the data into df and print: the number of rows, the title of the longest book (idxmax), and the average rating rounded to 2.
איך הפלט אמור להיראות?What should the output look like?
הוסיפו ל-df עמודה age (גיל הספר ב-2026) ועמודה size שהיא "short" מתחת ל-250 עמודים, אחרת "long". הדפיסו title, age, size לשלושת הספרים הוותיקים ביותר.
Add to df a column age (the book's age in 2026) and a column size that's "short" under 250 pages, otherwise "long". Print title, age, size for the three oldest books.
איך הפלט אמור להיראות?What should the output look like?
title age size
Emma 211 long
Persuasion 209 short
The Hobbit 89 long
מדף, צעד 24: סטטיסטיקת קריאהShelf, step 24: reading statistics
פרויקט מלווהCompanion project
כתבו stats(df) שמחזירה מילון עם: books (כמות), pages (סך עמודים), top_author (הסופר עם הכי הרבה עמודים), best_month (החודש עם הכי הרבה עמודים), ו-avg_rating (מעוגל ל-1).
Write stats(df) returning a dict with: books (count), pages (total pages), top_author (the author with the most pages), best_month (the month with the most pages), and avg_rating (rounded to 1).
איך הפלט אמור להיראות?What should the output look like?
books: 6
pages: 1893
top_author: Jane Austen
best_month: Feb
avg_rating: 4.3
כתבו clean(text) שמקבלת CSV מלוכלך (עמודות title, author, pages, rating) ומחזירה DataFrame נקי: כותרות וסופרים בלי רווחים מסביב, סופר חסר → unknown, שורות בלי pages נמחקות, pages כ-int, rating חסר → ממוצע הדירוגים (מעוגל ל-1), וכפילויות לפי title נמחקות (נשאר הראשון).
Write clean(text) taking a messy CSV (columns title, author, pages, rating) and returning a clean DataFrame: titles and authors stripped, missing author → unknown, rows without pages dropped, pages as int, missing rating → the mean rating (rounded to 1), and duplicates by title dropped (keep the first).
איך הפלט אמור להיראות?What should the output look like?
title author pages rating
Dune Frank Herbert 412 5.0
Emma unknown 474 4.5
Matilda Roald Dahl 240 4.0
main.py
רמזHint 1:df["title"] = df["title"].str.strip() לפני drop_duplicates.df["title"] = df["title"].str.strip() before drop_duplicates.
כתבו pivot(df) שמחזירה טבלה שבה כל שורה היא סופר, כל עמודה היא חודש (בסדר Jan, Feb, Mar, Apr), והערכים הם סכום עמודים (0 כשאין). השתמשו ב-pivot_table עם fill_value=0.
Write pivot(df) returning a table where each row is an author, each column a month (in order Jan, Feb, Mar, Apr), and values are page totals (0 where none). Use pivot_table with fill_value=0.
איך הפלט אמור להיראות?What should the output look like?
month Jan Feb Mar Apr
author
Frank Herbert 412 0 0 0
J. R. R. Tolkien 0 0 310 0
Jane Austen 0 474 0 249
Roald Dahl 0 240 208 0