title: How do you execute python without providing a file name?
body: <p>I am relatively new to python, so I was wondering if I could call upon python to read a string (or the code it needs to execute) from outside the interactive python shell, similar to how exec() works when within Python.
  Basically, I want to know if there is any method to have python read code from the command line or otherwise rather than having to save that code within a 'file.py' or another similar file. 
  I want to avoid running this: <code>python file.py</code> as I hope to avoid needing a filename.
  I was looking around for a solution and found <a href="https://stackoverflow.com/questions/10768584/execute-python-commands-passed-as-strings-in-command-line-using-python-c">Execute python commands passed as strings in command line using python -c</a> and <a href="https://stackoverflow.com/questions/163542/python-how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument">Python - How do I pass a string into subprocess.Popen (using the stdin argument)?</a>. The first answer seems to be what I might want, but I lack in the knowledge department of how to pass the string into stdin, so I would be grateful if someone could better explain that method if it is the correct answer. The second link was what I found when looking up about stdin, and looked promising, but upon execution I realized that, from my understanding, I still need some sort of file name for subprocess. 
  I was planning to use this in order to be used in Jupyter Notebook, or any similar program so when I run one data cell, it is able to be executed in Python or return the error message, but to first do that I have to find out how to reference the language I want without needing a file name. Thank you for your time and consideration!</p>