{ "cells": [ { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "###
San Jose State University
Department of Applied Data Science

**DATA 200
Computational Programming for Data Analytics**

Spring 2024
Instructor: Ron Mak
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exploratory Data Analysis (EDA)\n", "#### During EDA, you might perform **descriptive statistics** to describe and summarize the data. Basic descriptive statistics include:\n", "- **minimum**: the smallest value in the data\n", "- **maximum**: the largest value in the data\n", "- **range**: the range of values in the data, from the minimum to the maximum\n", "- **count**: the count of values in the data\n", "- **sum**: the sum of the values in the data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Here's some Python code that prompts the user for three integer values and then determines which is the minimum value." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Get the three integer values from the user.\n", "n1 = int(input('First number? '))\n", "n2 = int(input('Second number? '))\n", "n3 = int(input('Third number? '))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# First assume the minimum is the n1 value.\n", "minimum = n1\n", "which = 'first'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Now find the real minimum value. Could it be n2?\n", "if n2 < minimum:\n", " minimum = n2\n", " which = 'second'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Note that unlike languages like Java and C++, Python does not use braces `{` and `}` to define statement blocks. Instead, Python relies on indentation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Or maybe it's n3.\n", "if n3 < minimum:\n", " minimum = n3\n", " which = 'third'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Print the minimum value.\n", "print('The minimum value is', minimum)\n", "print('It was the', which, 'value')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### We can also write the above code as a standalone Python program: `FindMin.py`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2.9 Intro to Data Science: Basic Descriptive Statistics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Determining the Minimum and Maximum with Built-In Functions `min` and `max` " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "min(36, 27, 12)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "max(36, 27, 12)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### **EXERCISE:** For the values `47`, `95`, `88`, `73`, `88` and `84` calculate the minimum, maximum and range." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "##########################################################################\n", "# (C) Copyright 2019 by Deitel & Associates, Inc. and #\n", "# Pearson Education, Inc. All Rights Reserved. #\n", "# #\n", "# DISCLAIMER: The authors and publisher of this book have used their #\n", "# best efforts in preparing the book. These efforts include the #\n", "# development, research, and testing of the theories and programs #\n", "# to determine their effectiveness. The authors and publisher make #\n", "# no warranty of any kind, expressed or implied, with regard to these #\n", "# programs or to the documentation contained in these books. The authors #\n", "# and publisher shall not be liable in any event for incidental or #\n", "# consequential damages in connection with, or arising out of, the #\n", "# furnishing, performance, or use of these programs. #\n", "##########################################################################\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Additional material (C) copyright 2023 by Ronald Mak" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.5" } }, "nbformat": 4, "nbformat_minor": 4 }