Home assignment 1

Home assignment 1#

Last updated: 2024-12-11 17:43:07

Question 1#

  • From the 'Institutio' column in the 'education.csv' file, choose an intitution name that starts with the same letter as your first or last name (for example, 'מולדת' if your first name is 'מיכאל'). You can do this step manually, e.g., in Excel, and not in your Python code. (See Convert CSV file to a different encoding for code that can be used to convert a CSV file to the windows-1255 encoding.)

  • Define a str variable with the selected name

  • Find and print the name ('Institutio' column) and type ('type' column) of the selected institution, in one line, separated by commas

  • If there is more than one institution having the selected name—then you need to print the string with name and type for each institution

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

מולדת, בית ספר
מולדת, גן ילדים

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.

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

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