W6-C1 作业

11-1
def printnames(city,country):
	return city.title()+","+country.title()
import unittest
from hello_world import printnames

class PrintTestCase(unittest.TestCase):
	def test_print(self):
		answer=printnames("beijing","china")
		self.assertEqual(answer,"Beijing,China")

unittest.main()


11-2
def printnames(city,country,population):
	return city.title()+","+country.title()+"-"+str(population)
import unittest
from hello_world import printnames

class PrintTestCase(unittest.TestCase):
	def test_print(self):
		answer=printnames("santiago","chile",5000000)
		self.assertEqual(answer,"Santiago,Chile-5000000")

unittest.main()

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页