Is it possible to embed a python script into HTML? For example:
name = input("What is your name?")
print("Hi, " + name)
If so, can it use modules, for example datetime, os, sys, random?
If I'm understanding your question correctly, you'd actually do the opposite. You would serve HTML from your Python script. You could use whatever modules you like in your Python application along with whatever modules are necessary for you to serve HTML content.
There are many web frameworks for doing such. Django is perhaps the most popular but it may be too robust for what you want to do.
Perhaps check out Flask?
edit: Not to mention Python has a built-in method for serving up web content, Python WSGI (Web Server Gateway Interface), you can read more about Python WSGI here.
<script type="text/x-python">