Code works but still getting 7 errors

@kitanikita Can you help me out on this one?
Here is the link to my code : https://repl.it/@HemantPatra/fcc-demographic-data-analyzer-1#demographic_data_analyzer.py

The code runs fine and gives all the outputs but the console shows 7 error. Is the code not correct?

Number of each race:
 race
Amer-Indian-Eskimo      311
Asian-Pac-Islander     1039
Black                  3124
Other                   271
White                 27816
Name: race, dtype: int64
Average age of men: 39.43
Percentage with Bachelors degrees: 16.45%
Percentage with higher education that earn >50K: 10.71%
Percentage without higher education that earn >50K: 24.08%
Min work time: 1 hours/week
Percentage of rich among those who work fewest hours: 10.0%
Country with highest percentage of rich: United-States
Highest percentage of rich people in country: 91.46%
Top occupations in India: Prof-specialty
EEEEE.EE..
======================================================================
ERROR: test_average_age_men (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 16, in test_average_age_men
    self.assertAlmostEqual(actual, expected, "Expected different value for average age of men.")
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: an integer is required (got type str)

======================================================================
ERROR: test_higher_education_rich (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 26, in test_higher_education_rich
    self.assertAlmostEqual(actual, expected, "Expected different value for percentage with higher education that earn >50K.")
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: 'str' object cannot be interpreted as an integer

======================================================================
ERROR: test_highest_earning_country (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 46, in test_highest_earning_country
    self.assertAlmostEqual(actual, expected, "Expected different value for highest earning country.")
  File "/usr/lib/python3.8/unittest/case.py", line 943, in assertAlmostEqual
    diff = abs(first - second)
TypeError: unsupported operand type(s) for -: 'str' and 'str'

======================================================================
ERROR: test_highest_earning_country_percentage (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 51, in test_highest_earning_country_percentage
    self.assertAlmostEqual(actual, expected, "Expected different value for heighest earning country percentage.")
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: an integer is required (got type str)

======================================================================
ERROR: test_lower_education_rich (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 31, in test_lower_education_rich
    self.assertAlmostEqual(actual, expected, "Expected different value for percentage without higher education that earn >50K.")
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: 'str' object cannot be interpreted as an integer

======================================================================
ERROR: test_percentage_bachelors (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 21, in test_percentage_bachelors
    self.assertAlmostEqual(actual, expected, "Expected different value for percentage with Bachelors degrees.")
  File "/usr/lib/python3.8/unittest/case.py", line 957, in assertAlmostEqual
    if round(diff, places) == 0:
TypeError: 'str' object cannot be interpreted as an integer

======================================================================
ERROR: test_race_count (test_module.DemographicAnalyzerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/fcc-demographic-data-analyzer-1/test_module.py", line 11, in test_race_count
    self.assertAlmostEqual(actual, expected, "Expected race count values to be [27816, 3124, 1039, 311, 271]")
  File "/usr/lib/python3.8/unittest/case.py", line 943, in assertAlmostEqual
    diff = abs(first - second)
TypeError: unsupported operand type(s) for -: 'list' and 'list'

----------------------------------------------------------------------
Ran 10 tests in 4.678s

FAILED (errors=7)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like