Exemple #1
0
def main():
    print(
        "1. View total votes in the U.S. for every election year from 2000 to 2016."
    )
    print(
        "2. Compares the number of votes and percentages for Republicans and Democrats for any state from 2000-2016"
    )
    print(
        "3. View the top 5 Republican states in either the 2012 or 2016 elections"
    )
    print(
        "4. View the top 5 Democrat states in either the 2012 or 2016 elections"
    )
    print("5. View Florida's Republican votes from 1976-2016")
    print("6. View Florida's Democrat votes from 1976-2016")
    print(
        "7. View a color-coded map of the 2016 U.S. Presidential Election results"
    )
    print("8. View third party votes in the U.S. from 1976-2016")

    choice = int(input("Choose one option (ex: 1) "))

    if choice == 1:
        print(P1.total_votes())
        P1.total_votes_map()
    elif choice == 2:
        state_input = input("Type in a state (ex: District of Columbia) ")
        print(P2.compare_votes(state_input))
        P2.compare_votes_map(state_input)
    elif choice == 3:
        year = int(
            input("Choose an election year. Type in either 2012 or 2016: "))
        if year == 2012:
            print(P3.rep_states2012())
            P3.rep_states_2012_plot()
        elif year == 2016:
            print(P3.rep_states2016())
            P3.rep_states_2016_plot()
    elif choice == 4:
        year = int(
            input("Choose an election year. Type in either 2012 or 2016: "))
        if year == 2012:
            print(P3.dem_states2012())
            P3.dem_states_2012_plot()
        elif year == 2016:
            print(P3.dem_states2016())
            P3.dem_states_2016_plot()
    elif choice == 5:
        print(P4.fl_repvotes())
        P4.florida_rep_votes_plot()
    elif choice == 6:
        print(P4.fl_demvotes())
        P4.florida_dem_votes_plot()
    elif choice == 7:
        print(P6.us_map_2016())
    elif choice == 8:
        print(P7.total_non_rd())
        P7.total_non_rd_map()
    else:
        main()
Exemple #2
0
 def test_mix2(self):
     entrada = ["come", "HoLa", "come", "bien", "bien", "bien"]
     salida = {"hola": 1, "come": 2, "bien": 3}
     self.assertEqual(salida, P7.cuenta_palabras(entrada))
Exemple #3
0
 def test_mix(self):
     entrada = ["hola", "HoLa", "BYE"]
     salida = {"hola": 2, "bye": 1}
     self.assertEqual(salida, P7.cuenta_palabras(entrada))
Exemple #4
0
 def test_mayusc(self):
     entrada = ["HOLA", "HOLA", "BIEN"]
     salida = {"hola": 2, "bien": 1}
     self.assertEqual(salida, P7.cuenta_palabras(entrada))
Exemple #5
0
 def test_minusc(self):
     entrada = ["hola", "hola", "bien"]
     salida = {"hola": 2, "bien": 1}
     self.assertEqual(salida, P7.cuenta_palabras(entrada))
Exemple #6
0
 def test_vacio(self):
     entrada = []
     salida = {}
     self.assertEqual(salida, P7.cuenta_palabras(entrada))
if l_sPath not in os.environ['PATH']:
    os.environ['PATH'] += os.pathsep + l_sPath
os.environ['P7_BIN'] = l_sPath

import P7

#-------------------------------------------------------------------------------
#registering P7 client - transport engine. Every client can handle up to 32
#individual channels (telemetry, trace).
#You may do it once for many scripts running as single program, or create
#many clients with unique names and reuse them by trace or telemetry channels.
#Creating it one you can reuse it from different modules.
#N.B.: information about argument string parameters is located in documentation
P7.Register_Client(
    P7.UTF(u"MyClient"),
    P7.UTF(
        u"/P7.Addr=localhost /P7.Sink=Auto /P7.Pool=8192 /P7.Name=PytonExample"
    ))

#-------------------------------------------------------------------------------
#creating telemetry channel or getting already created one (by name)
#Client with name "MyClient" have to be created before
l_cTel = P7.Get_Telemetry_Channel(P7.UTF(u"MyTelemetry"), P7.UTF(u"MyClient"))

#create 2 telemetry counters
bId1 = l_cTel.Create(P7.UTF(u"MyCounter1"), 0, 1000, 950, 950, 1)
bId2 = l_cTel.Create(P7.UTF(u"MyCounter2"), 0, 1000, 950, 950, 1)

#deliver telemetry samples
for num in range(0, 10000):
    l_cTel.Add(bId1, num % 1000)