|
46 | 46 | },
|
47 | 47 | {
|
48 | 48 | "cell_type": "code",
|
49 |
| - "execution_count": 2, |
| 49 | + "execution_count": 1, |
50 | 50 | "metadata": {},
|
51 | 51 | "outputs": [
|
52 | 52 | {
|
|
63 | 63 | "read_file = reader(opened_file)\n",
|
64 | 64 | "apps_data = list(read_file)\n",
|
65 | 65 | "\n",
|
| 66 | + "\n", |
66 | 67 | "ratings = []\n",
|
67 | 68 | "for row in apps_data[1:]:\n",
|
68 | 69 | " rating = float(row[7])\n",
|
|
123 | 124 | },
|
124 | 125 | {
|
125 | 126 | "cell_type": "code",
|
126 |
| - "execution_count": 43, |
| 127 | + "execution_count": null, |
127 | 128 | "metadata": {},
|
128 | 129 | "outputs": [],
|
| 130 | + "source": [] |
| 131 | + }, |
| 132 | + { |
| 133 | + "cell_type": "code", |
| 134 | + "execution_count": 6, |
| 135 | + "metadata": {}, |
| 136 | + "outputs": [ |
| 137 | + { |
| 138 | + "name": "stdout", |
| 139 | + "output_type": "stream", |
| 140 | + "text": [ |
| 141 | + "3.3767258382642997\n" |
| 142 | + ] |
| 143 | + } |
| 144 | + ], |
129 | 145 | "source": [
|
130 | 146 | "## Start your code below:\n",
|
| 147 | + "opened_file = open('AppleStore.csv', encoding='utf8')\n", |
| 148 | + "from csv import reader\n", |
| 149 | + "read_file = reader(opened_file)\n", |
| 150 | + "apps_data = list(read_file)\n", |
| 151 | + "\n", |
| 152 | + "free_apps_ratings = []\n", |
| 153 | + "\n", |
| 154 | + "\n", |
| 155 | + "for row in apps_data[1:]: ##for each row in the dataset\n", |
| 156 | + " rating = float(row[7]) ##the variable rating is a float of the 7th column in each row\n", |
| 157 | + " price=float(row[4]) ##the variable price is a float of the 4th column in each row\n", |
| 158 | + " if price==0.0: ##if the price is 0.0\n", |
| 159 | + " free_apps_ratings.append(rating) #then the rating is added to the free_apps_rating\n", |
| 160 | + "\n", |
| 161 | + "avg_rating_free = sum(free_apps_ratings) / len(free_apps_ratings) ##computing the average\n", |
| 162 | + "print(avg_rating_free)\n", |
131 | 163 | "\n",
|
132 | 164 | "\n"
|
133 | 165 | ]
|
|
224 | 256 | },
|
225 | 257 | {
|
226 | 258 | "cell_type": "code",
|
227 |
| - "execution_count": 47, |
| 259 | + "execution_count": 7, |
228 | 260 | "metadata": {},
|
229 |
| - "outputs": [ |
230 |
| - { |
231 |
| - "name": "stdout", |
232 |
| - "output_type": "stream", |
233 |
| - "text": [ |
234 |
| - "10\n" |
235 |
| - ] |
236 |
| - } |
237 |
| - ], |
| 261 | + "outputs": [], |
238 | 262 | "source": [
|
239 | 263 | "#1. A Boolean value.\n",
|
240 | 264 | "\n",
|
|
363 | 387 | },
|
364 | 388 | {
|
365 | 389 | "cell_type": "code",
|
366 |
| - "execution_count": 52, |
| 390 | + "execution_count": 9, |
367 | 391 | "metadata": {},
|
368 |
| - "outputs": [], |
| 392 | + "outputs": [ |
| 393 | + { |
| 394 | + "name": "stdout", |
| 395 | + "output_type": "stream", |
| 396 | + "text": [ |
| 397 | + "this is not free\n" |
| 398 | + ] |
| 399 | + } |
| 400 | + ], |
369 | 401 | "source": [
|
370 |
| - "price = 0\n", |
| 402 | + "price = 4\n", |
371 | 403 | "\n",
|
372 |
| - "#start your code here:\n" |
| 404 | + "#start your code here:\n", |
| 405 | + "if price ==0:\n", |
| 406 | + " print(\"this is free\")\n", |
| 407 | + "else: \n", |
| 408 | + " if price>0:\n", |
| 409 | + " print(\"this is not free\")\n" |
373 | 410 | ]
|
374 | 411 | },
|
375 | 412 | {
|
|
454 | 491 | },
|
455 | 492 | {
|
456 | 493 | "cell_type": "code",
|
457 |
| - "execution_count": 55, |
| 494 | + "execution_count": 10, |
458 | 495 | "metadata": {},
|
459 | 496 | "outputs": [
|
460 | 497 | {
|
|
522 | 559 | },
|
523 | 560 | {
|
524 | 561 | "cell_type": "code",
|
525 |
| - "execution_count": 58, |
| 562 | + "execution_count": 13, |
526 | 563 | "metadata": {},
|
527 |
| - "outputs": [], |
| 564 | + "outputs": [ |
| 565 | + { |
| 566 | + "name": "stdout", |
| 567 | + "output_type": "stream", |
| 568 | + "text": [ |
| 569 | + "3.720948742438714\n" |
| 570 | + ] |
| 571 | + } |
| 572 | + ], |
528 | 573 | "source": [
|
529 | 574 | "# INITIAL CODE\n",
|
530 | 575 | "opened_file = open('AppleStore.csv', encoding='utf8')\n",
|
531 | 576 | "from csv import reader\n",
|
532 | 577 | "read_file = reader(opened_file)\n",
|
533 | 578 | "apps_data = list(read_file)\n",
|
534 | 579 | "\n",
|
535 |
| - "free_apps_ratings = []\n", |
| 580 | + "non_free_apps_ratings = []\n", |
536 | 581 | "for row in apps_data[1:]:\n",
|
537 | 582 | " rating = float(row[7])\n",
|
538 | 583 | " price = float(row[4]) \n",
|
539 |
| - " if price == 0.0:\n", |
540 |
| - " free_apps_ratings.append(rating)\n", |
| 584 | + " if price != 0.0:\n", |
| 585 | + " non_free_apps_ratings.append(rating)\n", |
541 | 586 | " \n",
|
542 |
| - "avg_rating_free = sum(free_apps_ratings) / len(free_apps_ratings)" |
| 587 | + "avg_rating_non_free = sum(non_free_apps_ratings) / len(non_free_apps_ratings)\n", |
| 588 | + "print(avg_rating_non_free)" |
543 | 589 | ]
|
544 | 590 | },
|
545 | 591 | {
|
|
638 | 684 | },
|
639 | 685 | {
|
640 | 686 | "cell_type": "code",
|
641 |
| - "execution_count": 63, |
| 687 | + "execution_count": 16, |
642 | 688 | "metadata": {},
|
643 |
| - "outputs": [], |
| 689 | + "outputs": [ |
| 690 | + { |
| 691 | + "name": "stdout", |
| 692 | + "output_type": "stream", |
| 693 | + "text": [ |
| 694 | + "3.343928035982009\n" |
| 695 | + ] |
| 696 | + } |
| 697 | + ], |
644 | 698 | "source": [
|
645 | 699 | "#reading the dataset\n",
|
646 | 700 | "opened_file = open('AppleStore.csv', encoding='utf8')\n",
|
|
650 | 704 | "\n",
|
651 | 705 | "#start your code here:\n",
|
652 | 706 | "#Initialize an empty list named non_games_ratings.\n",
|
| 707 | + "non_games_ratings=[]\n", |
| 708 | + "for row in apps_data[1:]:\n", |
| 709 | + " rating=float(row[7])\n", |
| 710 | + " genre=row[11]\n", |
| 711 | + "\n", |
| 712 | + " if genre !='Games':\n", |
| 713 | + " non_games_ratings.append(rating)\n", |
| 714 | + "avg_ratings_non_games=sum(non_games_ratings)/len(non_games_ratings)\n", |
| 715 | + "print(avg_ratings_non_games)\n", |
653 | 716 | "\n",
|
654 | 717 | "#Loop through the apps_data\n",
|
655 | 718 | "\n",
|
|
1054 | 1117 | },
|
1055 | 1118 | {
|
1056 | 1119 | "cell_type": "code",
|
1057 |
| - "execution_count": 79, |
| 1120 | + "execution_count": 18, |
1058 | 1121 | "metadata": {},
|
1059 |
| - "outputs": [], |
| 1122 | + "outputs": [ |
| 1123 | + { |
| 1124 | + "name": "stdout", |
| 1125 | + "output_type": "stream", |
| 1126 | + "text": [ |
| 1127 | + "3.8904235727440146\n" |
| 1128 | + ] |
| 1129 | + } |
| 1130 | + ], |
1060 | 1131 | "source": [
|
1061 | 1132 | "opened_file = open('AppleStore.csv', encoding='utf8')\n",
|
1062 | 1133 | "from csv import reader\n",
|
1063 | 1134 | "read_file = reader(opened_file)\n",
|
1064 | 1135 | "apps_data = list(read_file)\n",
|
1065 | 1136 | "\n",
|
1066 |
| - "free_games_social_ratings = []\n", |
| 1137 | + "non_free_games_social_ratings = []\n", |
1067 | 1138 | "for row in apps_data[1:]:\n",
|
1068 | 1139 | " rating = float(row[7])\n",
|
1069 | 1140 | " genre = row[11]\n",
|
1070 | 1141 | " price = float(row[4])\n",
|
1071 | 1142 | " \n",
|
1072 |
| - " if (genre == 'Social Networking' or genre == 'Games') and price == 0:\n", |
1073 |
| - " free_games_social_ratings.append(rating)\n", |
| 1143 | + " if (genre == 'Social Networking' or genre == 'Games') and price != 0:\n", |
| 1144 | + " non_free_games_social_ratings.append(rating)\n", |
1074 | 1145 | " \n",
|
1075 |
| - "avg_free = sum(free_games_social_ratings) / len(free_games_social_ratings)\n", |
| 1146 | + "avg_non_free = sum(non_free_games_social_ratings) / len(non_free_games_social_ratings)\n", |
| 1147 | + "print(avg_non_free)\n", |
1076 | 1148 | "\n",
|
1077 | 1149 | "# Non-free apps (average)"
|
1078 | 1150 | ]
|
|
1555 | 1627 | },
|
1556 | 1628 | {
|
1557 | 1629 | "cell_type": "code",
|
1558 |
| - "execution_count": 94, |
| 1630 | + "execution_count": 20, |
1559 | 1631 | "metadata": {},
|
1560 | 1632 | "outputs": [],
|
1561 | 1633 | "source": [
|
|
1567 | 1639 | "\n",
|
1568 | 1640 | "for app in apps_data[1:]:\n",
|
1569 | 1641 | " price = float(app[4])\n",
|
1570 |
| - " # Complete code from here" |
| 1642 | + " # Complete code from here\n", |
| 1643 | + " if price==0.0:\n", |
| 1644 | + " app.append(\"free)\")\n", |
| 1645 | + " elif price >0 and price< 20:\n", |
| 1646 | + " app.append(\"affordable\")\n", |
| 1647 | + " elif price >=20 and price <50:\n", |
| 1648 | + " app.append(\"expensive\")\n", |
| 1649 | + " elif price >= 50: \n", |
| 1650 | + " app.append(\"very expensive\")\n", |
| 1651 | + "apps_data[0].append(\"price_label\")" |
1571 | 1652 | ]
|
| 1653 | + }, |
| 1654 | + { |
| 1655 | + "cell_type": "code", |
| 1656 | + "execution_count": 22, |
| 1657 | + "metadata": {}, |
| 1658 | + "outputs": [ |
| 1659 | + { |
| 1660 | + "name": "stdout", |
| 1661 | + "output_type": "stream", |
| 1662 | + "text": [ |
| 1663 | + "['id', 'track_name', 'size_bytes', 'currency', 'price', 'rating_count_tot', 'rating_count_ver', 'user_rating', 'user_rating_ver', 'ver', 'cont_rating', 'prime_genre', 'sup_devices.num', 'ipadSc_urls.num', 'lang.num', 'vpp_lic', 'price_label']\n" |
| 1664 | + ] |
| 1665 | + } |
| 1666 | + ], |
| 1667 | + "source": [ |
| 1668 | + "print(apps_data[0])" |
| 1669 | + ] |
| 1670 | + }, |
| 1671 | + { |
| 1672 | + "cell_type": "code", |
| 1673 | + "execution_count": null, |
| 1674 | + "metadata": {}, |
| 1675 | + "outputs": [], |
| 1676 | + "source": [] |
1572 | 1677 | }
|
1573 | 1678 | ],
|
1574 | 1679 | "metadata": {
|
|
1587 | 1692 | "name": "python",
|
1588 | 1693 | "nbconvert_exporter": "python",
|
1589 | 1694 | "pygments_lexer": "ipython3",
|
1590 |
| - "version": "3.7.1" |
| 1695 | + "version": "3.11.5" |
1591 | 1696 | }
|
1592 | 1697 | },
|
1593 | 1698 | "nbformat": 4,
|
|
0 commit comments