Write a program that reads in babynames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and girls. Write a program that reads the above two files into 2 lists containing tuples (rank, name) Sort them based on the names - be sure ranks are sorted based on names print all names that are both boy and girl names (such as Alexis or Morgan). Everything has to be inside functions - the main function (on the top) should be calling functions. ////////////////////////////////////////////////////////////// IN PYTHON ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// babynames.txt ////////////////////////////////////////////////////////////// 1 Jacob 1.0013% Sophia 1.1297% 2 Mason 0.9637% Isabella 1.0282% 3 William 0.8522% Emma 0.9724% 4 Jayden 0.8378% Olivia 0.8940% 5 Noah 0.8307% Ava 0.8010% 6 Michael 0.8247% Emily 0.7375% 7 Ethan 0.8231% Abigail 0.6847% 8 Alexander 0.7746% Madison 0.6404% 9 Aiden 0.7646% Mia 0.5963% 10 Daniel 0.7521% Chloe 0.5685% 11 Anthony 0.7046% Elizabeth 0.5193% 12 Matthew 0.6981% Ella 0.4947% 13 Elijah 0.6865% Addison 0.4815% 14 Joshua 0.6758% Natalie 0.4475% 15 Liam 0.6632% Lily 0.4224% 16 Andrew 0.6535% Grace 0.3937% 17 James 0.6525% Samantha 0.3817% 18 David 0.6508% Avery 0.3803% 19 Benjamin 0.6430% Sofia 0.3793% 20 Logan 0.6416% Aubrey 0.3715% 21 Christopher 0.6402% Brooklyn 0.3705% 22 Joseph 0.6359% Lillian 0.3571% 23 Jackson 0.6100% Victoria 0.3558% 24 Gabriel 0.6075% Evelyn 0.3473% 25 Ryan 0.5676% Hannah 0.3383% 26 Samuel 0.5564% Alexis 0.3375% 27 John 0.5433% Charlotte 0.3314% 28 Nathan 0.5178% Zoey 0.3309% 29 Lucas 0.5130% Leah 0.3300% 30 Christian 0.5082% Amelia 0.3284% 31 Jonathan 0.5041% Zoe 0.3246% 32 Caleb 0.4926% Hailey 0.3245% 33 Dylan 0.4820% Layla 0.3149% 34 Landon 0.4820% Gabriella 0.3145% 35 Isaac 0.4724% Nevaeh 0.3140% 36 Gavin 0.4457% Kaylee 0.3124% 37 Brayden 0.4453% Alyssa 0.3105% 38 Tyler 0.4352% Anna 0.2917% 39 Luke 0.4291% Sarah 0.2849% 40 Evan 0.4265% Allison 0.2825% 41 Carter 0.4248% Savannah 0.2815% 42 Nicholas 0.4232% Ashley 0.2795% 43 Isaiah 0.4179% Audrey 0.2699% 44 Owen 0.4114% Taylor 0.2685% 45 Jack 0.4033% Brianna 0.2685% 46 Jordan 0.3979% Aaliyah 0.2646% 47 Brandon 0.3858% Riley 0.2605% 48 Wyatt 0.3789% Camila 0.2581% 49 Julian 0.3755% Khloe 0.2561% 50 Aaron 0.3754% Claire 0.2536% 51 Jeremiah 0.3731% Sophie 0.2442% 52 Angel 0.3722% Arianna 0.2427% 53 Cameron 0.3701% Peyton 0.2418% 54 Connor 0.3659% Harper 0.2414% 55 Hunter 0.3625% Alexa 0.2332% 56 Adrian 0.3623% Makayla 0.2299% 57 Henry 0.3560% Julia 0.2248% 58 Eli 0.3551% Kylie 0.2248% 59 Justin 0.3508% Kayla 0.2234% 60 Austin 0.3468% Bella 0.2206% 61 Robert 0.3430% Katherine 0.2166% 62 Charles 0.3427% Lauren 0.2122% 63 Thomas 0.3405% Gianna 0.2104% 64 Zachary 0.3347% Maya 0.2071% 65 Jose 0.3344% Sydney 0.2053% 66 Levi 0.3260% Serenity 0.1990% 67 Kevin 0.3244% Kimberly 0.1969% 68 Sebastian 0.3231% Mackenzie 0.1961% 69 Chase 0.3054% Autumn 0.1947% 70 Ayden 0.3023% Jocelyn 0.1932% 71 Jason 0.2880% Faith 0.1914% 72 Ian 0.2771% Lucy 0.1912% 73 Blake 0.2768% Stella 0.1909% 74 Colton 0.2761% Jasmine 0.1906% 75 Bentley 0.2750% Morgan 0.1895%
Write a program that reads in babynames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and girls.
Write a program that reads the above two files into 2 lists containing tuples (rank, name)
Sort them based on the names - be sure ranks are sorted based on names
print all names that are both boy and girl names (such as Alexis or Morgan).
Everything has to be inside functions - the main function (on the top) should be calling functions.
////////////////////////////////////////////////////////////// IN PYTHON //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////// babynames.txt //////////////////////////////////////////////////////////////
1 Jacob 1.0013% Sophia 1.1297% 2 Mason 0.9637% Isabella 1.0282% 3 William 0.8522% Emma 0.9724% 4 Jayden 0.8378% Olivia 0.8940% 5 Noah 0.8307% Ava 0.8010% 6 Michael 0.8247% Emily 0.7375% 7 Ethan 0.8231% Abigail 0.6847% 8 Alexander 0.7746% Madison 0.6404% 9 Aiden 0.7646% Mia 0.5963% 10 Daniel 0.7521% Chloe 0.5685% 11 Anthony 0.7046% Elizabeth 0.5193% 12 Matthew 0.6981% Ella 0.4947% 13 Elijah 0.6865% Addison 0.4815% 14 Joshua 0.6758% Natalie 0.4475% 15 Liam 0.6632% Lily 0.4224% 16 Andrew 0.6535% Grace 0.3937% 17 James 0.6525% Samantha 0.3817% 18 David 0.6508% Avery 0.3803% 19 Benjamin 0.6430% Sofia 0.3793% 20 Logan 0.6416% Aubrey 0.3715% 21 Christopher 0.6402% Brooklyn 0.3705% 22 Joseph 0.6359% Lillian 0.3571% 23 Jackson 0.6100% Victoria 0.3558% 24 Gabriel 0.6075% Evelyn 0.3473% 25 Ryan 0.5676% Hannah 0.3383% 26 Samuel 0.5564% Alexis 0.3375% 27 John 0.5433% Charlotte 0.3314% 28 Nathan 0.5178% Zoey 0.3309% 29 Lucas 0.5130% Leah 0.3300% 30 Christian 0.5082% Amelia 0.3284% 31 Jonathan 0.5041% Zoe 0.3246% 32 Caleb 0.4926% Hailey 0.3245% 33 Dylan 0.4820% Layla 0.3149% 34 Landon 0.4820% Gabriella 0.3145% 35 Isaac 0.4724% Nevaeh 0.3140% 36 Gavin 0.4457% Kaylee 0.3124% 37 Brayden 0.4453% Alyssa 0.3105% 38 Tyler 0.4352% Anna 0.2917% 39 Luke 0.4291% Sarah 0.2849% 40 Evan 0.4265% Allison 0.2825% 41 Carter 0.4248% Savannah 0.2815% 42 Nicholas 0.4232% Ashley 0.2795% 43 Isaiah 0.4179% Audrey 0.2699% 44 Owen 0.4114% Taylor 0.2685% 45 Jack 0.4033% Brianna 0.2685% 46 Jordan 0.3979% Aaliyah 0.2646% 47 Brandon 0.3858% Riley 0.2605% 48 Wyatt 0.3789% Camila 0.2581% 49 Julian 0.3755% Khloe 0.2561% 50 Aaron 0.3754% Claire 0.2536% 51 Jeremiah 0.3731% Sophie 0.2442% 52 Angel 0.3722% Arianna 0.2427% 53 Cameron 0.3701% Peyton 0.2418% 54 Connor 0.3659% Harper 0.2414% 55 Hunter 0.3625% Alexa 0.2332% 56 Adrian 0.3623% Makayla 0.2299% 57 Henry 0.3560% Julia 0.2248% 58 Eli 0.3551% Kylie 0.2248% 59 Justin 0.3508% Kayla 0.2234% 60 Austin 0.3468% Bella 0.2206% 61 Robert 0.3430% Katherine 0.2166% 62 Charles 0.3427% Lauren 0.2122% 63 Thomas 0.3405% Gianna 0.2104% 64 Zachary 0.3347% Maya 0.2071% 65 Jose 0.3344% Sydney 0.2053% 66 Levi 0.3260% Serenity 0.1990% 67 Kevin 0.3244% Kimberly 0.1969% 68 Sebastian 0.3231% Mackenzie 0.1961% 69 Chase 0.3054% Autumn 0.1947% 70 Ayden 0.3023% Jocelyn 0.1932% 71 Jason 0.2880% Faith 0.1914% 72 Ian 0.2771% Lucy 0.1912% 73 Blake 0.2768% Stella 0.1909% 74 Colton 0.2761% Jasmine 0.1906% 75 Bentley 0.2750% Morgan 0.1895%Trending now
This is a popular solution!
Step by step
Solved in 2 steps