Python Code For Generating And Testing