Is Xcode 7.3 compatible with Homebrew on Sierra? I am a beginner and while attempting to get my Macbook Pro (early 2011, 4 GB RAM) ready for an online class (Python for DNA sequencing data analysis) I apparently did something wrong.  I first downloaded Xcode (v7) from the App store.  I chose version 7 because a friend said version 8 was crashing on him and also I've read that one may have both versions if they are placed in different folders.  I agreed to the Xcode licence then installed Homebrew by running the script from the Homebrew website in Terminal. It installed successfully.  Next I tried to insert the Homebrew directory at the top of path.  I did this by first creating a .bash_profile file, opened the file and inserted: export PATH=/usr/local/bin:/usr/local/sbin:$PATH.  This is when everything froze and I could not restart or force quit.  Waited for the power to die then recharged.  The computer is very slow now and Preview will not quit (tried many ways to force quit).  Preview will not allow a restart or shutdown.  Is problem from downloading the wrong version of software, or perhaps from messing with the Path?  Any ideas to solve the immediate issue with Preview and overall software installation guidance would be much appreciated.
For starters, if you were editing the .bash_profile in your user folder it should not be able to cause system-wide issues, the most you would experience is a lack of ability to run software installed by Homebrew if you mistyped the line. To be safe though, I would remove this line from your bash profile if possible. Homebrew auto-links software it installs into the /usr/bin/ and /opt/local/ directories, so you don't have to add anything to the $PATH for ot to work properly. 

As far as Xcode goes I am on Sierra and version 8 has worked fine for me, but version 7 was extremely glitchy when I was running El Capitan. Not to mention that version 8 is about half the size of version 7, so I would recommend uninstalling version 7 and replacing it with version 8.

With Homebrew in particular there is the issue that it requires both the Xcode app, and the Xcode command line tools (a quick search will reveal how to install them from the Terminal) so if you don't have both it could cause issues.

Finally do you have System Integrity Protection disabled? Some features of Xcode require root to run, and the Xcode app is allowed to make changes to the system, even if SIP is enabled. Homebrew on the other hand requires root permission to install properly but will be denied access to modify the core system if SIP is enabled, so its possible that Homebrew made some system modifications through Xcode, some modifications to the non-SIP-protected root folders, and was denied access to modify the SIP-protected root folders, resulting in a half modified, partially linked and generally unstable system. You can check if SIP is enabled (if you don't know) by running the command csrutil in the terminal. If it is enabled, and you have a recent time machine backup, I would recommend rebooting to your recovery partition, restoring your system with the backup, opening a terminal while in the recovery, running csrutil disable, and rebooting to macOS. From there install the Xcode command line tools if you don't have them, and try the process again with Xcode 8 instead. While this isn't for sure the issue, SIP can cause problems when used with software that modifies the system, and seeing as how you have enough IT know-how to be installing Xcode and a command line package manager in the first place I recommend disabling it to be safe as a rule.