خرید بک لینک

Vote count: 0

I am trying to make a button that takes in the state a person lives in and their race and outputs their life expectancy. I have a long list of data for all the states and various races. I also have my button set up, but need to find a way to use this data in an efficient way that allows the button to take in the two pieces of information and output one number, the life expectancy that correctly corresponds.

Thanks! Here is what I have so far-

def life_expectancy_race(b):  
    '''This will tell you your life expectancy based on the information    plugged into the boxes.'''
    #number = print(text_input1.value) and print(text_input2.value)
    display.clear_output()
    display.display(display.Latex("Your life expectancy is {} y    ears".format(life)))


text_input1= widgets.Text(description='Enter the state you live in here')
text_input2= widgets.Text(description='Enter your race here (White, Native      American, Latino, Asian American, African American )')
button = widgets.Button(description='What is my life expectancy?')
button.on_click(life_expectancy_race)

display.display(text_input1)
display.display(text_input2)
display.display(button)

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 24 فروردين 1395 ساعت: 11:41

صفحه بندی