File size: 1,411 Bytes
7747336
 
 
 
 
 
 
 
 
 
 
fc41014
 
c8924bf
 
7747336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d577d44
ad5b7ab
7747336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8924bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
 "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
}