Add notebook for container datatypes
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
		
							parent
							
								
									d59ec6069b
								
							
						
					
					
						commit
						fb0fed2247
					
				
							
								
								
									
										121
									
								
								notebooks/containertypes.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								notebooks/containertypes.ipynb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,121 @@
 | 
			
		||||
{
 | 
			
		||||
 "cells": [
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Erweiterte Datentypen: Container"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Listen und Tupel"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": 4,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [
 | 
			
		||||
    {
 | 
			
		||||
     "name": "stdout",
 | 
			
		||||
     "output_type": "stream",
 | 
			
		||||
     "text": [
 | 
			
		||||
      "[5, 10, 20, 30, 50]\n",
 | 
			
		||||
      "[0.5, 0.6, 0.8, 1.0, 1.2]\n",
 | 
			
		||||
      "['Joe', 'Alice', 'Bob', 'Charly']\n",
 | 
			
		||||
      "[1, 'Joe', 1.4, 'Alice', 100]\n",
 | 
			
		||||
      "['one'] [] []\n"
 | 
			
		||||
     ]
 | 
			
		||||
    }
 | 
			
		||||
   ],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Listenliterale\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "values = [5, 10, 20, 30, 50]\n",
 | 
			
		||||
    "print(values)\n",
 | 
			
		||||
    "fractions = [0.5, 0.6, 0.8, 1.0, 1.2]\n",
 | 
			
		||||
    "print(fractions)\n",
 | 
			
		||||
    "names = [\"Joe\", \"Alice\", \"Bob\", \"Charly\"]\n",
 | 
			
		||||
    "print(names)\n",
 | 
			
		||||
    "heap = [1, \"Joe\", 1.4, \"Alice\", 100]\n",
 | 
			
		||||
    "print(heap)\n",
 | 
			
		||||
    "single = [\"one\"]\n",
 | 
			
		||||
    "leer = []\n",
 | 
			
		||||
    "auch_leer = list()\n",
 | 
			
		||||
    "print(single, leer, auch_leer)"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": 8,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [
 | 
			
		||||
    {
 | 
			
		||||
     "name": "stdout",
 | 
			
		||||
     "output_type": "stream",
 | 
			
		||||
     "text": [
 | 
			
		||||
      "(5, 10, 20, 30, 50)\n",
 | 
			
		||||
      "(0.5, 0.6, 0.8, 1.0, 1.2)\n",
 | 
			
		||||
      "('Joe', 'Alice', 'Bob', 'Charly')\n",
 | 
			
		||||
      "(1, 'Joe', 1.4, 'Alice', 100)\n",
 | 
			
		||||
      "('one',) ('one',) ()\n"
 | 
			
		||||
     ]
 | 
			
		||||
    }
 | 
			
		||||
   ],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Tuplelliterale\n",
 | 
			
		||||
    "values = (5, 10, 20, 30, 50)\n",
 | 
			
		||||
    "print(values)\n",
 | 
			
		||||
    "fractions = (0.5, 0.6, 0.8, 1.0, 1.2)\n",
 | 
			
		||||
    "print(fractions)\n",
 | 
			
		||||
    "names = (\"Joe\", \"Alice\", \"Bob\", \"Charly\")\n",
 | 
			
		||||
    "print(names)\n",
 | 
			
		||||
    "heap = (1, \"Joe\", 1.4, \"Alice\", 100)\n",
 | 
			
		||||
    "print(heap)\n",
 | 
			
		||||
    "t_single = (\"one\",)\n",
 | 
			
		||||
    "t_auch_single = \"one\",\n",
 | 
			
		||||
    "t_leer = ()\n",
 | 
			
		||||
    "print(t_single, t_auch_single, t_leer)\n"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": null,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Umwandlung\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "l = [1, 2, 3, 4, 5]\n",
 | 
			
		||||
    "t= tuple(t)\n",
 | 
			
		||||
    "print(l, t)\n",
 | 
			
		||||
    "l = [10, 20, 30, 40, 50]\n",
 | 
			
		||||
    "print(l, t)\n"
 | 
			
		||||
   ]
 | 
			
		||||
  }
 | 
			
		||||
 ],
 | 
			
		||||
 "metadata": {
 | 
			
		||||
  "kernelspec": {
 | 
			
		||||
   "display_name": "softed",
 | 
			
		||||
   "language": "python",
 | 
			
		||||
   "name": "softed"
 | 
			
		||||
  },
 | 
			
		||||
  "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.8"
 | 
			
		||||
  }
 | 
			
		||||
 },
 | 
			
		||||
 "nbformat": 4,
 | 
			
		||||
 "nbformat_minor": 2
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user