You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
360 KiB
Plaintext

3 years ago
{
"cells": [
{
"cell_type": "markdown",
"id": "99e1ca1a",
"metadata": {},
"source": [
"# utility to create permutative identities\n",
"using mario as appeared in super mario brother game as an example"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "2a9cadc2",
"metadata": {},
"outputs": [],
"source": [
"adj_l = [\"speculative\",\"productive\",\"playful\",\"historical\",\"interdependent\"]\n",
"role_l = [\"programmer\",\"archivist\",\"publisher\"]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6d2c519c-26e6-4952-aab9-011d6b14729f",
"metadata": {},
"outputs": [],
"source": [
"# utility to check word starts with a vowel \n",
"# given a string, check the first item in the string, if it is any of a e i o u, then it starts with vowel\n",
"\n",
"def isVowel(str):\n",
" vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n",
" first_l = str[0]\n",
" #try not to use the iterative method \n",
" # found method on stackoverflow using the \"any\" function \n",
" return any(str[0] in vowel for vowel in vowels)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a10a1cdd-2858-4438-98f7-d2748ff6bbac",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'print_out_l' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_237445/1268294289.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# shuffle the list for fun\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mrandom\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshuffle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprint_out_l\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprint_out_l\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'print_out_l' is not defined"
]
}
],
"source": [
"# shuffle the list for fun \n",
"import random \n",
"random.shuffle(print_out_l)\n",
"print(print_out_l)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8182280d-e1b6-4fa0-903c-d3cad6dd10ea",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fd644698a60>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVYAAAI7CAYAAAC3LbOaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAJPAAACTwH3kTiQAAEAAElEQVR4nOz9Z7Bt2XHfCf5yrbX3Pu76+2xZFFAgPEAA9KRISiRlZiY0oWHItDqkGUqt7hgjqceFPs6X6VDMlw5Na6JDPTFSc0hJLfW0TEskJRIEHdiESBAgTKGAQvl69r77rj1um7VyPqy1j7nPv6pXqHr1suq+e885+2y7Vq7Mf/4zU1RVuYU0TcP169cxxtxqk0fySB7JI3kkSUIIbG1t4W61wT/+x/+YD37wg/z4D/wwFCv0Tj/Bz/7c/xa3vkVpBM0tY6/UMt+FKrCgpq2C3EptC7dV2EFAuaXOx8ryd0MI84OLIAv7DiGwuH6IcRhrCE2Fs0JmFN+UZM4gBJ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hPe8zpCEEi5gcJUO8xOcvFlmAvdqAz2zfS1Nuec4YDbgQtbxqPH5QT1mOeOGFb1AahaqkqUqqSckfDr9J7ixVOaXICqomeklBFZuwz6DKaNrwW7/9RSaTcYSyVPEhYsFiojIf+xojcPi7v894NEGDxxlD8NHTinM0zvOyqnn+uZd5+aVL0QIlBsWsszSqeO+jVewbqqrm6EvPkWWWxkfrs6w9QcG6GCwNTUDEUAc4GH6FuvE03hNQDB6TYKiI+yvqA9aOuX5tyHQ8gTbuEQJImoPGcFQ2YA2f+60
"text/plain": [
"<Figure size 750x750 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#rewrite the function with a name called identity shuffler\n",
"# supply the function with your own lists of content and ponder upon these identities \n",
"# sample code for mario character\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib.pyplot import figure\n",
"\n",
"figure(num=None,figsize=(50,50),dpi=15,facecolor='w',edgecolor='k')\n",
"im = plt.imread('mario_diversity.JPG')\n",
"plt.imshow(im) "
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "01b92ed1",
"metadata": {},
"outputs": [],
"source": [
"# names, descriptives and identities \n",
"name = \"mario\"\n",
"adj_l = [\"strategic\",\"reflective\",\"implicated\"]\n",
"role_l = [\"gamer\",\"plumber\"]\n",
"\n",
"\n",
"def identity_shuffler(name, adj_l,role_l):\n",
" # vars \n",
" counter = 0\n",
" \n",
" print(\"{} is: \".format(name))\n",
"\n",
" print_out = \"\"\n",
" print_out_l = []\n",
" \n",
" # loop over the items in the two lists in permutations, use nested for loop\n",
" for adj in adj_l:\n",
" for role in role_l:\n",
" counter = counter + 1\n",
" if isVowel(adj) is True:\n",
" # for precision, if the adj starts with a vowel, should print the indefinite article 'an'\n",
" print_out = str(counter) + \". \" + \"an \" + adj + \" \" + role\n",
" # append print out to a new list \n",
" print_out_l.append(print_out)\n",
" print(\"{}. an {} {}\".format(counter,adj,role))\n",
" else:\n",
" print_out = str(counter) + \". \" + \"a \" + adj + \" \" + role\n",
" print_out_l.append(print_out)\n",
" print(\"{}. a {} {}\".format(counter,adj,role))\n",
" print(\"printing file list {}\".format(print_out_l)) "
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "55e4ecc0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mario is: \n",
"1. a strategic gamer\n",
"2. a strategic plumber\n",
"3. a reflective gamer\n",
"4. a reflective plumber\n",
"5. an implicated gamer\n",
"6. an implicated plumber\n",
"printing file list ['1. a strategic gamer', '2. a strategic plumber', '3. a reflective gamer', '4. a reflective plumber', '5. an implicated gamer', '6. an implicated plumber']\n"
]
}
],
"source": [
"identity_shuffler(name,adj_l,role_l)"
]
}
],
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}