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.

360 KiB

utility to create permutative identities

using mario as appeared in super mario brother game as an example

In [3]:
adj_l = ["speculative","productive","playful","historical","interdependent"]
role_l = ["programmer","archivist","publisher"]
In [4]:
# utility to check word starts with a vowel 
# 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

def isVowel(str):
    vowels = ["a","e","i","o","u"]
    first_l = str[0]
    #try not to use the iterative method 
    # found method on stackoverflow using the "any" function 
    return any(str[0] in vowel for vowel in vowels)
In [5]:
# shuffle the list for fun 
import random 
random.shuffle(print_out_l)
print(print_out_l)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_237445/1268294289.py in <module>
      1 # shuffle the list for fun
      2 import random
----> 3 random.shuffle(print_out_l)
      4 print(print_out_l)

NameError: name 'print_out_l' is not defined
In [6]:
#rewrite the function with a name called identity shuffler
# supply the function with your own lists of content and ponder upon these identities 
# sample code for mario character

import matplotlib.pyplot as plt
from matplotlib.pyplot import figure

figure(num=None,figsize=(50,50),dpi=15,facecolor='w',edgecolor='k')
im = plt.imread('mario_diversity.JPG')
plt.imshow(im) 
Out[6]:
<matplotlib.image.AxesImage at 0x7fd644698a60>
In [27]:
# names, descriptives and identities 
name = "mario"
adj_l = ["strategic","reflective","implicated"]
role_l = ["gamer","plumber"]


def identity_shuffler(name, adj_l,role_l):
    # vars 
    counter = 0
    
    print("{} is: ".format(name))

    print_out = ""
    print_out_l = []
    
    # loop over the items in the two lists in permutations, use nested for loop
    for adj in adj_l:
        for role in role_l:
            counter = counter + 1
            if isVowel(adj) is True:
                # for precision, if the adj starts with a vowel, should print the indefinite article 'an'
                print_out = str(counter) + ". " + "an " + adj + " " + role
                # append print out to a new list 
                print_out_l.append(print_out)
                print("{}. an {} {}".format(counter,adj,role))
            else:
                print_out = str(counter) + ". " + "a " + adj + " " + role
                print_out_l.append(print_out)
                print("{}. a {} {}".format(counter,adj,role))
    print("printing file list {}".format(print_out_l))    
In [30]:
identity_shuffler(name,adj_l,role_l)
mario is: 
1. a strategic gamer
2. a strategic plumber
3. a reflective gamer
4. a reflective plumber
5. an implicated gamer
6. an implicated plumber
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']