作业十2018.4.15

原创 2018年04月15日 19:53:03

11-1

import unittest
def city_country(city,country):
    return city+', '+country
class Nametest(unittest.TestCase):
    def test_city_country(self):
        string=city_country('Santiago','Chile')
        self.assertEqual(string,'Santiago, Chile')
unittest.main()

11-2

import unittest
def city_country(city,country,pop):
    return city+', '+country+' population- '+pop
class Nametest(unittest.TestCase):
    def test_city_country(self):
        string=city_country('Santiago','Chile','5000000')
        self.assertEqual(string,'Santiago, Chile population- 5000000')
unittest.main()

输出:

Ran 1 test in 0.000s

FAILED (failures=1)
import unittest
def city_country(city,country,popu):
    if popu:
        return city+', '+country+' population- '+popu
    else:
        return city + ', ' + country
class Nametest(unittest.TestCase):
    def test_city_country(self):
        string=city_country('Santiago','Chile','5000000')
        self.assertEqual(string,'Santiago, Chile population- 5000000')
unittest.main()

输出:

Ran 1 test in 0.000s

OK
import unittest
def city_country(city,country,popu):
    if popu:
        return city+', '+country+' population- '+popu
    else:
        return city + ', ' + country
class Nametest(unittest.TestCase):
    def test_city_country(self):
        string=city_country('Santiago','Chile',popu='5000000')
        self.assertEqual(string,'Santiago, Chile population- 5000000')
unittest.main()

输出:

Ran 1 test in 0.000s

OK

11-3

import unittest
class Employee():
    def __init__(self,firstname,lastname,annual_salary):
        self.firstname=firstname
        self.lastname=lastname
        self.salary=annual_salary
    def give_raise(self,number=5000):
        self.salary=self.salary+number
        return self.salary
class Test(unittest.TestCase):
    def setUp(self):
        self.number=[15000,20000]
        self.employ_one=Employee('Leborn','James',10000)
        self.employ_two=Employee('Stephen','Curry',10000)
    def test_give_default_raise(self):
        self.assertEqual(self.employ_one.give_raise(),self.number[0])
        self.assertEqual(self.employ_two.give_raise(),self.number[0])
    def test_give_custom_raise(self):
        self.assertEqual(self.employ_one.give_raise(10000), self.number[1])
        self.assertEqual(self.employ_two.give_raise(10000), self.number[1])
unittest.main()

输出:

Ran 2 tests in 0.001s

OK



视觉SLAM十四讲-ch3

  • 2017年11月14日 16:43
  • 5.91MB
  • 下载

周报2018.4.15

  这周可以说是特殊的一周,因为周六日参加了自学考试,感觉还行吧,嗯,我在卷子上的某一题上对判卷老师写道“考前不努力,考时很伤悲!”,我也知道当判卷老师看到我写的这句话会毫不犹豫地给我判个零分的…. ...
  • TGBTrial
  • TGBTrial
  • 2018-04-15 23:46:45
  • 14

2018.4.15 网络编程

//单纯的客户端服务端有个局限性,A客户端连接上以后,未处理完之前,B客户端连接只有等待//所以服务端最好将每个客户端封装到一个线程中class PicThread implements Runnab...
  • Breadw
  • Breadw
  • 2018-04-15 14:00:36
  • 1

HTML网页开发学习笔记(燕十八)-37 整齐的表格 作业

作业: 实现如下图所示的表格
  • kexin_power
  • kexin_power
  • 2016-07-13 16:24:20
  • 678

作业十

//加密器Scanner import java.util.Scanner; public class  ke2{ @SuppressWarnings({ "resource", "unused...
  • JoeZiran
  • JoeZiran
  • 2017-12-28 14:48:24
  • 29

微机原理程序

  • 2013年06月25日 17:03
  • 191KB
  • 下载

calculator

  • 2011年10月11日 16:39
  • 22KB
  • 下载

第二章作业题51.3(编写一个程序从键盘输入10个数,要求输出其中最小的。)

  • yueyue276081275
  • yueyue276081275
  • 2015-03-28 15:38:20
  • 423

The Art of Assembly Language

The Art of Assembly Language 1 Whats Wrong With Assembly Language 2 Whats Right With Assembly Langua...
  • ydfok
  • ydfok
  • 2006-11-09 22:17:00
  • 963
收藏助手
不良信息举报
您举报文章:作业十2018.4.15
举报原因:
原因补充:

(最多只允许输入30个字)