Carbon nanotubes can be either metallic or semiconducting. Their properties change significantly with doping and strain, and they are excellent candidates for nanoscale electronic devices and sensors. We have investigated the electronic and quantum transport properties of bent, deformed and tapered nanotubes, as well as nanotube-metal contacts, which will likely form components of future nanotube-based devices. Bent armchair nanotubes keep their metallic character up to fairly high angles, while metallic chiral nanotubes open a sizable gap at the Fermi level, indicating that they can be used as nanoscale strain sensors. Tapered armchair tubes remain metallic, while their zigzag counterparts are semiconducting, as expected. Ballistic transmission is very sensitive to interactions with the substrate and coupling to the contacts. Our ab initio calculations for NT/Al structures show substantial charge transfer and rehybridization effects, which strongly affect the quantum conductance. We have also investigated BN nanotubes that are intrinsically polar. For BN tubes in chiral or zigzag structures, the symmetry permits a pyroelectric field along the tube axis, which is of the order of kV/cm per nanotube. The pyro- and piezo-effects will likely be useful in nanoscale switches, resonators, actuators, and transducers. Another important aspect of nanotubular structures is their high Li uptake, with potential applications in high performance batteries. Our quantum simulations show that Li cannot penetrate nanotube walls unless large defect structures are present, and that high concentration of Li leads to aggregates in the interstitial channels. In collaboration with M. Buongiorno Nardelli, J.-L. Fattebert, V. Meunier, D. Orlikowski, C. Roland and Q. Zhao.