Repository: Qiskit/qiskit

Issue:
%qiskit_backend_overview returns ZeroDivisionError
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 0.18.3
- **Python version**: 3.8.10
- **Operating system**: macOS Big Sur Version 11.6 (Though running in Quantum Lab also produces this error)

### What is the current behavior?
Running the following code results in a `ZeroDivisionError`:
```
from qiskit import IBMQ
import qiskit.tools.jupyter
%matplotlib inline

%qiskit_backend_overview
```

This is the full stack trace returned:
```
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-5-e9e9700c904d> in <module>
      3 get_ipython().run_line_magic('matplotlib', 'inline')
      4 
----> 5 get_ipython().run_line_magic('qiskit_backend_overview', '')

~/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2305                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2306             with self.builtin_trap:
-> 2307                 result = fn(*args, **kwargs)
   2308             return result
   2309 

</Users/Matthew.Stypulkoski@ibm.com/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/decorator.py:decorator-gen-134> in qiskit_backend_overview(self, line)

~/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/qiskit/tools/jupyter/backend_overview.py in qiskit_backend_overview(self, line)
     44         backend_title = widgets.HTML(value=_value, layout=widgets.Layout(margin="0px 0px 0px 0px"))
     45 
---> 46         build_back_widgets = [backend_widget(b) for b in unique_hardware_backends]
     47 
     48         _backends = []

~/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/qiskit/tools/jupyter/backend_overview.py in <listcomp>(.0)
     44         backend_title = widgets.HTML(value=_value, layout=widgets.Layout(margin="0px 0px 0px 0px"))
     45 
---> 46         build_back_widgets = [backend_widget(b) for b in unique_hardware_backends]
     47 
     48         _backends = []

~/opt/anaconda3/envs/qiskit-env/lib/python3.7/site-packages/qiskit/tools/jupyter/backend_overview.py in backend_widget(backend)
    200                             sum_cx_err += param["value"]
    201                             num_cx += 1
--> 202         avg_cx_err = round(sum_cx_err / (num_cx), 4)
    203 
    204     cx_widget = widgets.HTML(value=f"<h5>{avg_cx_err}</h5>", layout=widgets.Layout())

ZeroDivisionError: division by zero
```

### Steps to reproduce the problem
Run the code snippet above


### What is the expected behavior?
The backend_overview widget should not error out and should return the expected backend overviews.




Discussion:

Resolving patch:
diff --git a/qiskit/tools/jupyter/backend_overview.py b/qiskit/tools/jupyter/backend_overview.py
--- a/qiskit/tools/jupyter/backend_overview.py
+++ b/qiskit/tools/jupyter/backend_overview.py
@@ -199,7 +199,8 @@ def backend_widget(backend):
                         if param["value"] != 1.0:
                             sum_cx_err += param["value"]
                             num_cx += 1
-        avg_cx_err = round(sum_cx_err / (num_cx), 4)
+        if num_cx > 0:
+            avg_cx_err = round(sum_cx_err / num_cx, 4)
 
     cx_widget = widgets.HTML(value=f"<h5>{avg_cx_err}</h5>", layout=widgets.Layout())
 


Test patch: