From 1489f18a515441c9e56d2c215f49e8115a5f89b4 Mon Sep 17 00:00:00 2001 From: Katherine Brunelle Date: Tue, 21 Jul 2015 18:04:29 -0400 Subject: [PATCH 1/2] Added the baby name generator --- ExampleCode/Python/BabyNameApp/README.md | 1 + ExampleCode/Python/BabyNameApp/babyGen.py | 54 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 ExampleCode/Python/BabyNameApp/README.md create mode 100644 ExampleCode/Python/BabyNameApp/babyGen.py diff --git a/ExampleCode/Python/BabyNameApp/README.md b/ExampleCode/Python/BabyNameApp/README.md new file mode 100644 index 0000000..cee7d7c --- /dev/null +++ b/ExampleCode/Python/BabyNameApp/README.md @@ -0,0 +1 @@ +This is the thing before things diff --git a/ExampleCode/Python/BabyNameApp/babyGen.py b/ExampleCode/Python/BabyNameApp/babyGen.py new file mode 100644 index 0000000..db0c1b3 --- /dev/null +++ b/ExampleCode/Python/BabyNameApp/babyGen.py @@ -0,0 +1,54 @@ +import requests, random, json, IsenseModule +""" +class Car(object): + condition = "new" + def __init__(self, model, color, mpg): + self.model = model + self.color = color + self.mpg = mpg + +my_car = Car("DeLorean", "silver", 88) +""" + +class name(object): + def __init__(self, name, gender, position): + self.name = name + self.gender = gender + self.position = position + def printNameStats(self): + print "Name: " + self.name + print "Gender: " + self.gender + print "Rank: " + str(self.position) + +boy_names = [] #171 boy names +girl_names = [] #169 girl names +gender = "none" +position = 0 +run = True + +boy_names = IsenseModule.getDatasetFieldData('503','Most Popular Boy Names','Child First Name') +girl_names = IsenseModule.getDatasetFieldData('503','Most Popular Girl Names','Child First Name') +all_names = boy_names + girl_names + +while (run == True): + rdm = random.randint(0,len(all_names)) + + if(rdm > 171): + #know that it's a girls name + position = rdm - 170 + gender = "Female" + else: + position = rdm + 1 + gender = "Male" + + my_name = name(all_names[rdm], gender, position) + print '' + my_name.printNameStats() + + #find a new name? false = true = false + while True: + cont = raw_input("Would you like to find another name (y/n)?") + if(cont != 'y') and (cont != 'Y'): + run = False + break + #else we consider it a 'no' From dbbf064cba9977852feacbb7feb7f80a9805c6a6 Mon Sep 17 00:00:00 2001 From: KatherineBrunelle Date: Tue, 21 Jul 2015 18:05:58 -0400 Subject: [PATCH 2/2] Update README.md --- ExampleCode/Python/BabyNameApp/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ExampleCode/Python/BabyNameApp/README.md b/ExampleCode/Python/BabyNameApp/README.md index cee7d7c..9871506 100644 --- a/ExampleCode/Python/BabyNameApp/README.md +++ b/ExampleCode/Python/BabyNameApp/README.md @@ -1 +1,2 @@ -This is the thing before things +#BABY NAME APP +This is an example of taking data off of iSENSE, by taking the data sets of most common boy and girl baby names and picking a random name to return to the user.