Python Code Using Functions And Mapping