# OBJECTIVE: Display statistics, table, and histogram of a set of cities and population of each city.

# prompt user for title of the data and output to the user
title = input("Enter a title for the data: ")
print(f'You entered: {title}')

# prompt user for headers of the two columns of the table
colOneHeader = input("Enter the column 1 header: ")
print(f'You entered: {colOneHeader}')
colTwoHeader = input("Enter the column 2 header: ")
print(f'You entered: {colTwoHeader}')

# prompt user for data points, string, int for city and population
cityData = []
cityPop = []
isDone = False
while(isDone != True):
    dataInput = input("Enter a data point('done to stop input): ")
    if(dataInput.lower() == 'done'):
        isDone = True
    else:
        name, pop = dataInput.split(',')
        print(f'City: {name}')
        print(f'Population: {pop}')
        dataPoint = {str(name), str(pop)}
        cityData.append(dataPoint)
        cityPop.append(int(pop))

histogramChar = input("Please enter the character for the histogram: ")
#  output min, max, and mean of the population data
# https://stackoverflow.com/questions/27009247/python-find-min-max-and-average-of-a-list-array


def cityStatistics(cityPop):
    maxValue = max(cityPop)
    minValue = min(cityPop)
    avgValue = sum(cityPop)/len(cityPop)
    print('')
    print('Population Statistics')
    print(f'Minimum: {minValue}')
    print(f'Maximum: {maxValue}')
    print(f'Mean: {avgValue:.3f}')
    print('')


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')

# uncomment to debug
# print(cityPop)
# print(cityData)


def histogramTable(histogramChar, CityPop):
    for pop in cityPop:
        popsChars = pop // 100000
        print(f'{histogramChar * popsChars}')

    # output data in a formatted table
cityStatistics(cityPop)
cityTable(cityData, title, colOneHeader, colTwoHeader)
# TODO: output data in a histogram; print one user-specified char for 100k peeps
histogramTable(histogramChar, cityPop)

0fbf8893984caf851ecb0d311dc127646b83fffb
<mask token>


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')


<mask token>

<mask token>


def cityStatistics(cityPop):
    maxValue = max(cityPop)
    minValue = min(cityPop)
    avgValue = sum(cityPop) / len(cityPop)
    print('')
    print('Population Statistics')
    print(f'Minimum: {minValue}')
    print(f'Maximum: {maxValue}')
    print(f'Mean: {avgValue:.3f}')
    print('')


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')


def histogramTable(histogramChar, CityPop):
    for pop in cityPop:
        popsChars = pop // 100000
        print(f'{histogramChar * popsChars}')


<mask token>

<mask token>
print(f'You entered: {title}')
<mask token>
print(f'You entered: {colOneHeader}')
<mask token>
print(f'You entered: {colTwoHeader}')
<mask token>
while isDone != True:
    dataInput = input("Enter a data point('done to stop input): ")
    if dataInput.lower() == 'done':
        isDone = True
    else:
        name, pop = dataInput.split(',')
        print(f'City: {name}')
        print(f'Population: {pop}')
        dataPoint = {str(name), str(pop)}
        cityData.append(dataPoint)
        cityPop.append(int(pop))
<mask token>


def cityStatistics(cityPop):
    maxValue = max(cityPop)
    minValue = min(cityPop)
    avgValue = sum(cityPop) / len(cityPop)
    print('')
    print('Population Statistics')
    print(f'Minimum: {minValue}')
    print(f'Maximum: {maxValue}')
    print(f'Mean: {avgValue:.3f}')
    print('')


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')


def histogramTable(histogramChar, CityPop):
    for pop in cityPop:
        popsChars = pop // 100000
        print(f'{histogramChar * popsChars}')


cityStatistics(cityPop)
cityTable(cityData, title, colOneHeader, colTwoHeader)
histogramTable(histogramChar, cityPop)

title = input('Enter a title for the data: ')
print(f'You entered: {title}')
colOneHeader = input('Enter the column 1 header: ')
print(f'You entered: {colOneHeader}')
colTwoHeader = input('Enter the column 2 header: ')
print(f'You entered: {colTwoHeader}')
cityData = []
cityPop = []
isDone = False
while isDone != True:
    dataInput = input("Enter a data point('done to stop input): ")
    if dataInput.lower() == 'done':
        isDone = True
    else:
        name, pop = dataInput.split(',')
        print(f'City: {name}')
        print(f'Population: {pop}')
        dataPoint = {str(name), str(pop)}
        cityData.append(dataPoint)
        cityPop.append(int(pop))
histogramChar = input('Please enter the character for the histogram: ')


def cityStatistics(cityPop):
    maxValue = max(cityPop)
    minValue = min(cityPop)
    avgValue = sum(cityPop) / len(cityPop)
    print('')
    print('Population Statistics')
    print(f'Minimum: {minValue}')
    print(f'Maximum: {maxValue}')
    print(f'Mean: {avgValue:.3f}')
    print('')


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')


def histogramTable(histogramChar, CityPop):
    for pop in cityPop:
        popsChars = pop // 100000
        print(f'{histogramChar * popsChars}')


cityStatistics(cityPop)
cityTable(cityData, title, colOneHeader, colTwoHeader)
histogramTable(histogramChar, cityPop)

# OBJECTIVE: Display statistics, table, and histogram of a set of cities and population of each city.

# prompt user for title of the data and output to the user
title = input("Enter a title for the data: ")
print(f'You entered: {title}')

# prompt user for headers of the two columns of the table
colOneHeader = input("Enter the column 1 header: ")
print(f'You entered: {colOneHeader}')
colTwoHeader = input("Enter the column 2 header: ")
print(f'You entered: {colTwoHeader}')

# prompt user for data points, string, int for city and population
cityData = []
cityPop = []
isDone = False
while(isDone != True):
    dataInput = input("Enter a data point('done to stop input): ")
    if(dataInput.lower() == 'done'):
        isDone = True
    else:
        name, pop = dataInput.split(',')
        print(f'City: {name}')
        print(f'Population: {pop}')
        dataPoint = {str(name), str(pop)}
        cityData.append(dataPoint)
        cityPop.append(int(pop))

histogramChar = input("Please enter the character for the histogram: ")
#  output min, max, and mean of the population data
# https://stackoverflow.com/questions/27009247/python-find-min-max-and-average-of-a-list-array


def cityStatistics(cityPop):
    maxValue = max(cityPop)
    minValue = min(cityPop)
    avgValue = sum(cityPop)/len(cityPop)
    print('')
    print('Population Statistics')
    print(f'Minimum: {minValue}')
    print(f'Maximum: {maxValue}')
    print(f'Mean: {avgValue:.3f}')
    print('')


def cityTable(cityData, title, colOneHeader, colTwoHeader):
    print(title)
    print(f'{colOneHeader}   |   {colTwoHeader}')
    print('-----------------------------------------')
    for pop, city in cityData:
        print(f'{city}    |    {pop}')

# uncomment to debug
# print(cityPop)
# print(cityData)


def histogramTable(histogramChar, CityPop):
    for pop in cityPop:
        popsChars = pop // 100000
        print(f'{histogramChar * popsChars}')

    # output data in a formatted table
cityStatistics(cityPop)
cityTable(cityData, title, colOneHeader, colTwoHeader)
# TODO: output data in a histogram; print one user-specified char for 100k peeps
histogramTable(histogramChar, cityPop)
