Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Def - Return Question
#1
Hi Everyone,

I'm trying to understand the below code. My question is why is it returning salary_bins?

So from what I understand it first defines the table columns, creates the bins and then draws the histograms.

But the return part I'm not sure I fully understand. I tried to run it with return salary_bins and it created the histograms as well.

Thanks in advance.

def histograms(t):
    ages = t.column('Age')
    salaries = t.column('Salary')
    age_bins = np.arange(min(ages),max(ages)+1,1)
    salary_bins = np.arange(min(salaries), max(salaries)+1000000,1000000)
    t.hist('Age', bins=age_bins, unit='year')
    t.hist('Salary', bins=salary_bins, unit='$')
    return age_bins # Keep this statement so that your work can be checked
    
histograms(full_data)
print('Two histograms should be displayed below')
Reply


Messages In This Thread
Def - Return Question - by tryingtolearnpython - Jul-01-2018, 08:11 AM
RE: Def - Return Question - by volcano63 - Jul-01-2018, 09:33 AM
RE: Def - Return Question - by tryingtolearnpython - Jul-01-2018, 11:04 AM
RE: Def - Return Question - by volcano63 - Jul-01-2018, 12:39 PM
RE: Def - Return Question - by tryingtolearnpython - Jul-04-2018, 03:13 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020