Created
August 6, 2025 20:01
-
-
Save fomightez/27f2e1c185ca318ed705d2d5a796fd4d to your computer and use it in GitHub Desktop.
Discourse discussion https://discourse.jupyter.org/t/errors-and-execution-of-the-same-code-in-jupyter-notebook-through-anaconda/37346?u=fomightez
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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "10425074-67df-44a2-8ec0-99305ccb4349", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "7" | |
| ] | |
| }, | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "3+4" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "685f4420-6ba2-4583-874c-400d06867889", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "60\n", | |
| "78\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "Weight=60\n", | |
| "weight=78\n", | |
| "\n", | |
| "print(Weight)\n", | |
| "print(weight)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "1a99ee8f-f749-43f5-b3df-5238c2526a7b", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "<class 'str'>\n", | |
| "<class 'int'>\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "patient_id = '1'\n", | |
| "PATIENT_id= 1\n", | |
| "\n", | |
| "print(type(patient_id))\n", | |
| "print(type(PATIENT_id))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "id": "a77e51b4-d40f-4f15-b7ad-afcda47c875d", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "132.0\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "A=2.2 * Weight\n", | |
| "print(A)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "id": "d159387c-2750-4341-b2b6-cfd49365753b", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "133.0\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "B=A+1\n", | |
| "print(B)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "id": "99c02596-d009-4279-ade4-33410183828f", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "inflam_1\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "# Convert PATIENT_id to string before concatenation\n", | |
| "patient_id_number = 'inflam_' + str(PATIENT_id)\n", | |
| "print(patient_id_number)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "9f8c45b5-f63c-49ee-bed6-306acf80644e", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "c= 'ox1ge3'\n", | |
| "len(c)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "90f599e8-0fdf-4005-9f42-7f538c6374fb", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "#The data is not final. \n", | |
| "\n", | |
| "patient_id = '1'\n", | |
| "PATIENT_id= 1\n", | |
| "\n", | |
| "print(type(patient_id))\n", | |
| "print(type(PATIENT_id))\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "2abdc599-e941-48b5-ad7c-ecf82287bef3", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "element = 'oxygen'\n", | |
| "element[1:-1]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "69887d2b-6e61-49be-95c2-3ab220f4d109", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "fruits=[\"apple\", \"banana\", \"cherry\", \"apple\"]\n", | |
| "fruits[1]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "id": "f925de2d-8929-42af-9b0c-8206ea7ef3c4", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "('apple', 'banana', 'cherry', 'apple')\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits = (\"apple\", \"banana\", \"cherry\", \"apple\")\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "61d6bc26-b2f8-4f27-8bf1-4c1207c96d2c", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "70d9c239-a1ff-4056-ac9b-ad8d50bc3e31", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "fruits.remove('pear')\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "9de784b1-7b74-4727-ab69-4786b26010cf", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "fruits = (\"apple\", \"banana\", \"cherry\", \"apple\")\n", | |
| "fruits[1]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "13cb312b-c425-40d5-9490-8d0c6882a36d", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "fruits[1]= 'pear'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "id": "e78b16f4-9836-4f34-a649-32515a31cd70", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "['apple', 'banana', 'cherry', 'apple']\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits_list = list(fruits)\n", | |
| "print(fruits_list)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 16, | |
| "id": "404d2c47-93b0-49c9-bb1f-3a72a100e129", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "['apple', 'banana', 'cherry', 'apple', 'lettuce']\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits_list.append('lettuce')\n", | |
| "print(fruits_list)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 17, | |
| "id": "b3795c8d-1105-44c2-af0e-12bdcf972cd1", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "['apple', 'banana', 'cherry', 'apple', 'lettuce', 'dragonfruit']\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits_list.append('dragonfruit')\n", | |
| "print(fruits_list)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "id": "d82141ce-0a9c-43d5-9f6a-73c2daec5bab", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'cherry', 'banana', 'apple'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits = {\"apple\", \"banana\", \"cherry\", \"apple\"}\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "id": "46b3071a-10e5-4e71-8ba5-a29758af3323", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'cherry', 'pear', 'banana', 'apple'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits.add('pear')\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "f26186bf-e4b2-4b66-9562-e906025d450d", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "# Option 1: Check if the item exists before removing\n", | |
| "fruits = ['apple', 'banana', 'orange'] # Example list, replace with your actual fruits list\n", | |
| "\n", | |
| "if 'cherry' in fruits:\n", | |
| " fruits.remove('cherry')\n", | |
| "else:\n", | |
| " print(\"'cherry' is not in the list\")\n", | |
| " \n", | |
| "print(fruits)\n", | |
| "\n", | |
| "# Option 2: Use try-except to handle the error\n", | |
| "# fruits = ['apple', 'banana', 'orange'] # Example list\n", | |
| "# try:\n", | |
| "# fruits.remove('cherry')\n", | |
| "# except ValueError:\n", | |
| "# print(\"'cherry' is not in the list\")\n", | |
| "# \n", | |
| "# print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "id": "e9ec2ab8-5849-4e72-bbbb-e2ccbc655c77", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'pear', 'banana', 'apple'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits.remove('cherry')\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "id": "a0d68534-d7d6-43f5-9052-d31c2da23311", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'pear', 'banana'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruits.remove('apple')\n", | |
| "print(fruits)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "id": "a6c782ed-af96-4898-8fed-d8117d1f12d1", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'apple': 'red', 'banana': 'yellow', 'cherry': 'red'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruit_colors = {\n", | |
| "\t\"apple\": \"red\",\n", | |
| "\t\"banana\": \"yellow\",\n", | |
| "\t\"cherry\": \"red\"}\n", | |
| "print(fruit_colors)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "id": "89806d6d-0f3a-40ce-894c-2244b3d3953a", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "'red'" | |
| ] | |
| }, | |
| "execution_count": 14, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "fruit_colors['apple']" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "id": "6b16fa58-6c50-4957-ae9c-e28f9940132a", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "{'apple': 'red', 'banana': 'purple', 'cherry': 'red'}\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "fruit_colors['banana']='purple'\n", | |
| "print(fruit_colors)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "44dcebd5-9e8a-4b84-beab-ef5e616e79e3", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "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.10.16" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment