I'm using xampp installed on Ubuntu.
What I did: [edited the following line in httpd.conf] AddHandler cgi-script .cgi .pl .asp .py
My python script present in htdocs is:
#!/usr/bin/python3
import cgitb
print("Content-Type: text/html;charset=utf-8\n")
print ("Hello Python Web Browser!! This is cool!!")
Output result is: End of script output before headers: sample.py