def test_c2f(self): """ Tests Celsius to Fahrenheit conversion""" self.assertEqual(212, temperature.c2f(100)) self.assertEqual(122, temperature.c2f(50)) self.assertEqual(32, temperature.c2f(0))
import temperature as t print('32摄氏度 = %.2f华氏度' % t.c2f(32)) print('99华氏度 = %.2f摄氏度' % t.f2c(99))
import temperature as tc print("32摄氏度 = %.2f华氏度" % tc.c2f(32)) print("99华氏度 = %.2f摄氏度" % tc.c2f(32))
def test_freezing(): """Test freezing point of water""" x = c2f(0) epis = pow(10, -15) assert abs(x - 32) < epis
def test_fever(): """Test temperature of fever""" x = c2f(340 / 9) epis = pow(10, -15) assert abs(x - 100) < epis
def test_body(): """Test normal body temperature""" x = c2f(37) epis = pow(10, -15) assert abs(x - 98.6) < epis
def test_boiling(): """Test boiling point of water""" x = c2f(100) epis = pow(10, -15) assert abs(x - 212) < epis