© 2019 authors. Published by the American Physical Society. Published by the American Physical Society under the terms of the https://creativecommons.org/licenses/by/4.0/ Creative Commons Attribution 4.0 International license. Further distribution of this work must maintain attribution to the author(s) and the published article's title, journal citation, and DOI. Funded by SCOAP 3 . Inelasticity, the fraction of a neutrino's energy transferred to hadrons, is a quantity of interest in the study of astrophysical and atmospheric neutrino interactions at multi-TeV energies with IceCube. In this work, a sample of contained neutrino interactions in IceCube is obtained from five years of data and classified as 2650 tracks and 965 cascades. Tracks arise predominantly from charged-current νμ interactions, and we demonstrate that we can reconstruct their energy and inelasticity. The inelasticity distribution is found to be consistent with the calculation of Cooper-Sarkar et al. across the energy range from ∼1 to ∼100 TeV. Along with cascades from neutrinos of all flavors, we also perform a fit over the energy, zenith angle, and inelasticity distribution to characterize the flux of astrophysical and atmospheric neutrinos. The energy spectrum of diffuse astrophysical neutrinos is described well by a power law in both track and cascade samples, and a best-fit index γ=2.62±0.07 is found in the energy range from 3.5 TeV to 2.6 PeV. Limits are set on the astrophysical flavor composition and are compatible with a ratio of (13â¶13â¶13)âŠ•. Exploiting the distinct inelasticity distribution of νμ and ν̄μ interactions, the atmospheric νμ to ν̄μ flux ratio in the energy range from 770 GeV to 21 TeV is found to be 0.77-0.25+0.44 times the calculation by Honda et al. Lastly, the inelasticity distribution is also sensitive to neutrino charged-current charm production. The data are consistent with a leading-order calculation, with zero charm production excluded at 91% confidence level. Future analyses of inelasticity distributions may probe new physics that affects neutrino interactions both in and beyond the Standard Model.