Home assignment 1

Home assignment 1#

Last updated: 2024-02-24 18:05:17

Question 1#

  • From the 'tree_speci' column in the 'trees.csv' file, choose a tree species that starts with the same letter as your first or last name (for example, 'מכנף נאה' if your first name is 'מיכאל').

  • Define a str variable with the selected species, and print it.

  • Calculate and print the number of times the string occurs in the 'tree_speci' column.

  • Note: use encoding='utf-8' when reading the file.

  • Hint: you can use a conditional, and a counter variable inside a for loop, to count the number of matching values.

מילה ירוקת עד
705

Question 2#

  • The 'stops.txt' file lists public transport stations in Israel, and includes the following columns:

    • 'stop_id'—Stop ID

    • 'stop_name'—Stop name

    • 'stop_lon'—Stop longitude

    • 'stop_lat'—Stop latitude

  • Using these four columns in the stops.txt file, find the IDs and names of all bus stops within a radius of 250 \(m\) around the Department of Geography at the Ben-Gurion University (34.800124,31.262794), collect them into a list of (stop_id,stop_name) tuples, and then print the list.

  • Use the distance function definition from Example: distance function to calculate the distances between each station and the Department of Geography.

  • Hint: use a conditional to append the corresponding station name to the list of results if the distance is smaller than 250.

[('26120', 'אוניברסיטת בן גוריון/יצחק רגר'),
 ('26130', 'אוניברסיטת בן גוריון/יצחק רגר'),
 ('26665', 'מרכז רפואי סורוקה/בן גוריון'),
 ('26669', 'מרפאות חוץ סורוקה/אוניברסיטת בן גוריון')]