def firstdigit1(number) : ''' Assume that number is an integer. Return the first digit of number. For example, if number is 523, then return 5 If number is -52, return 5 If number is 0, return 0 '''
import unittest
# --------------------------------------------------------------
# First digit of argument
# --------------------------------------------------------------
def firstdigit1(number) :
'''
Assume that number is an integer.
Return the first digit of number.
For example, if number is 523, then return 5
If number is -52, return 5
If number is 0, return 0
'''
pass
# --------------------------------------------------------------
# The Testing
# --------------------------------------------------------------
class myTests(unittest.TestCase):
def test1(self):
self.assertEqual(firstdigit1(57), 5)
def test2(self):
self.assertEqual(firstdigit1(0), 0)
def test3(self):
self.assertEqual(firstdigit1(-4343), 4)
def test4(self):
self.assertEqual(firstdigit1(10), 1)
def test5(self):
self.assertEqual(firstdigit1(500213), 5)
def test6(self):
self.assertEqual(firstdigit1(-47772210), 4)
if __name__ == '__main__':
unittest.main(exit=True)
Step by step
Solved in 4 steps with 2 images