Created
May 31, 2024 13:04
-
-
Save vuddameri/4a4657ad76a671951480c7879ef29709 to your computer and use it in GitHub Desktop.
DataTypes.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "provenance": [], | |
| "authorship_tag": "ABX9TyMvcx6g9oaE6ReDhHfKh/eQ", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "language_info": { | |
| "name": "python" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/vuddameri/4a4657ad76a671951480c7879ef29709/datatypes.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "6CI_DvW3PP2w", | |
| "outputId": "ae11d0d6-14d3-49e2-f7f0-3db134c8e1fe" | |
| }, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "<class 'int'>\n", | |
| "<class 'float'>\n", | |
| "<class 'complex'>\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "# Defining Variables with Basic Data Types\n", | |
| "# Numeric data\n", | |
| "a = 65000000000000000000\n", | |
| "b = 3.414\n", | |
| "c = 2 + 3j\n", | |
| "print(type(a))\n", | |
| "print(type(b))\n", | |
| "print(type(c))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# Boolean and String Data Types\n", | |
| "x = True\n", | |
| "y = 'I love Python'\n", | |
| "print(type(x))\n", | |
| "print(type(y))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "ysPaSaQJQ3yq", | |
| "outputId": "717b1b9e-0a1a-460e-dd10-5b661176d838" | |
| }, | |
| "execution_count": null, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "<class 'bool'>\n", | |
| "<class 'str'>\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "import datetime as dt\n", | |
| "t = dt.date(2024,5,31)\n", | |
| "print(t)\n", | |
| "print(type(t))\n" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "YaksfzjXYFTp", | |
| "outputId": "28c853da-5006-48bc-d82e-053b4d97be06" | |
| }, | |
| "execution_count": null, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "2024-05-31\n", | |
| "<class 'datetime.date'>\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "import numpy as np\n", | |
| "f16 = np.float16(22/7)\n", | |
| "f32 = np.float32(22/7)\n", | |
| "f64 = np.float64(22/7)\n", | |
| "print(\"The value of 22/7 as float16: \",f16)\n", | |
| "print(\"The value of 22/7 as float32: \",f32)\n", | |
| "print(\"The value of 22/7 as float64: \",f64)\n", | |
| "type(f32)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "KDzLvJrjY-J5", | |
| "outputId": "f70708f1-a7f5-4e1a-bd16-211b123563c5" | |
| }, | |
| "execution_count": null, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "The value of 22/7 as float16: 3.143\n", | |
| "The value of 22/7 as float32: 3.142857\n", | |
| "The value of 22/7 as float64: 3.142857142857143\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "numpy.float32" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 12 | |
| } | |
| ] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment