{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "parameters-cell", "metadata": { "tags": ["parameters"] }, "outputs": [], "source": [ "import json\n", "\n", "with open('/tmp/input.txt', 'r') as f:\n", " fruits = f.read().splitlines()" ] }, { "cell_type": "code", "execution_count": null, "id": "price-lookup", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "# Example fruit price dictionary\n", "fruit_prices = {\n", " 'apple': 1.2,\n", " 'banana': 0.5,\n", " 'orange': 0.8,\n", " 'grape': 2.5,\n", " 'mango': 1.8\n", "}\n", "\n", "# Look up prices\n", "prices = [(fruit, fruit_prices.get(fruit, 'N/A')) for fruit in fruits]\n", "df = pd.DataFrame(prices, columns=['Fruit', 'Price'])\n", "\n", "# Convert to CSV\n", "csv_output = df.to_csv('/tmp/output.csv',index=False)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }