Skip to content

Instantly share code, notes, and snippets.

@skbhati199
Created March 21, 2023 14:01
Show Gist options
  • Select an option

  • Save skbhati199/aed021936caf2ee2efb85edc5b3d5a0d to your computer and use it in GitHub Desktop.

Select an option

Save skbhati199/aed021936caf2ee2efb85edc5b3d5a0d to your computer and use it in GitHub Desktop.
03_Practice+Exercise+1.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/skbhati199/aed021936caf2ee2efb85edc5b3d5a0d/03_practice-exercise-1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "XW7auKdfbDyV"
},
"source": [
"## Practice Exercise 1"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0VwyOKvsbDyY"
},
"source": [
"You are provided with 2 lists that contain the data of an ecommerce website. The first list contains the data for the number of items sold for a particular product and the second list contains the price of the product sold. As a part of this exercise, solve the questions that are provided below."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"id": "mYJPxcpnbDyY"
},
"outputs": [],
"source": [
"number = [8, 9, 9, 1, 6, 9, 5, 7, 3, 9, 7, 3, 4, 8, 3, 5, 8, 4, 8, 7, 5, 7, 3, 6, 1, 2, 7, 4, 7, 7, 8, 4, 3, 4, 2, 2, 2, 7, 3, 5, 6, 1, 1, 3, 2, 1, 1, 7, 7, 1, 4, 4, 5, 6, 1, 2, 7, 4, 5, 8, 1, 4, 8, 6, 2, 4, 3, 7, 3, 6, 2, 3, 3, 3, 2, 4, 6, 8, 9, 3, 9, 3, 1, 8, 6, 6, 3, 3, 9, 4, 6, 4, 9, 6, 7, 1, 2, 8, 7, 8, 1, 4]\n",
"price = [195, 225, 150, 150, 90, 60, 75, 255, 270, 225, 135, 195, 30, 15, 210, 105, 15, 30, 180, 60, 165, 60, 45, 225, 180, 90, 30, 210, 150, 15, 270, 60, 210, 180, 60, 225, 150, 150, 120, 195, 75, 240, 60, 45, 30, 180, 240, 285, 135, 165, 180, 240, 60, 105, 165, 240, 120, 45, 120, 165, 285, 225, 90, 105, 225, 45, 45, 45, 75, 180, 90, 240, 30, 30, 60, 135, 180, 15, 255, 180, 270, 135, 105, 135, 210, 180, 135, 195, 225, 75, 225, 15, 240, 60, 15, 180, 255, 90, 15, 150, 230, 150]"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xpbQfs-zbDya"
},
"source": [
"#### How many different products are sold by the company in total?\n",
"\n",
"- 99\n",
"- 100\n",
"- 101\n",
"- 102\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "WUcyDdGWbDya",
"outputId": "1caa054d-2d8a-4b41-ae16-a5207ee200de"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"102\n"
]
}
],
"source": [
"# Type your code here\n",
"import numpy as np\n",
"\n",
"number = np.array(number)\n",
"price = np.array(price)\n",
"\n",
"print(number.size)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c4S_bu6hbDyb"
},
"source": [
"#### How many items were sold in total?\n",
"\n",
"- 460\n",
"- 490\n",
"- 500\n",
"- 520\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "XSozjU0obDyb",
"outputId": "9e1d20e1-d251-495c-c7bb-63a19efa5ae3"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"490\n"
]
}
],
"source": [
"# Type your code here\n",
"\n",
"print(number.sum())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "mpLtJQ1rbDyb"
},
"source": [
"#### What is the average price of the products sold by the ecommerce company?\n",
"\n",
"- 139\n",
"- 151\n",
"- 142\n",
"- 128"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "WVamlMyqbDyb",
"outputId": "7032d436-ef73-411c-a25f-c5ac280364d8"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"139.01960784313727\n"
]
}
],
"source": [
"# Type your code here\n",
"print(price.mean())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "lZI57ILwbDyb"
},
"source": [
"#### What is the price of the costliest item sold?\n",
"\n",
"- 225\n",
"- 310\n",
"- 280\n",
"- 285"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "O7vQSCsBbDyc",
"outputId": "5aa06374-8791-4be2-8c20-87f45cd65b39"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"285\n"
]
}
],
"source": [
"# Type your code here\n",
"print(price.max())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "uJw-4vN3bDyc"
},
"source": [
"#### What is the total revenue of the company? [Revenue = Price\\*Quantity]\n",
"\n",
"- 67100\n",
"- 53900\n",
"- 45300\n",
"- 71200"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "N-baTNfVbDyc",
"outputId": "eaae0181-830f-4958-9f9d-7ecf04fbbffd"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"67100"
]
},
"metadata": {},
"execution_count": 10
}
],
"source": [
"# Type your code here\n",
"np.sum(price*number)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"id": "jLYzTdqqbDyc"
},
"source": [
"#### Demand for the 20th product in the list is more than the 50th product. [True/False]\n",
"- True\n",
"- False\n",
"- Can't be calculated"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "pVE8KWOhbDyc",
"outputId": "b95aa730-d5bf-4e90-d8b1-f2ebab8e8955"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"True\n"
]
}
],
"source": [
"# Type your code here\n",
"# print(price.sum()*number.sum())\n",
"print(number[19]>number[49])"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "y736AytybDyd"
},
"source": [
"#### How many products fall under the category of expensive goods? \n",
"An expensive good is that good whose price is more than the average price of the products sold by the company.\n",
"\n",
"- 48\n",
"- 50\n",
"- 52\n",
"- 54"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "GoHrY_7nbDyd",
"outputId": "3e5c45d1-30e3-4d5d-d17e-ed1819763efd"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"52\n"
]
}
],
"source": [
"# Type your code here\n",
"def expensive(price):\n",
" count = 0\n",
" mean = price.mean()\n",
" for i in price:\n",
" if i>mean:\n",
" count+=1\n",
" return count\n",
"\n",
"x = expensive(price)\n",
"print(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "HrqlZKxbbDyd"
},
"outputs": [],
"source": []
}
],
"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.7.0"
},
"colab": {
"provenance": [],
"include_colab_link": true
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment