Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Logic in Python Try and Except

Float? What is that?

It may be because I haven't been putting as many hours as I need to in order to remember everything I'm working on, but I don't even remember working on floats before. I feel better about my progression now as I have succeeded at passing 2 straight challenges in 1 try, no errors, and no help needed, but this one has got me really puzzled.

trial.py
def add(num1, num2):
    return(num1+num2)

float = add(3, 7)
print(float)

2 Answers

Hello!

I guess you're stuck at Task 2, which is Let's make sure we're always working with floats. Convert your arguments to floats before you add them together. You can do this with the float() function.

The task requires you to convert them to floats before you add them together. You're currently converting the result of the function.

Hope that hint helped!

I don't understand how to do that. I don't even remember using the float function in any previous tasks.

Craig Webber
Craig Webber
5,677 Points

A computer reads number in binary either 16,32 or 64 bits. float is the way a computer interprets numbers with decimals. for instance 0.125. you do not really need to understand how python interprets each bit to determine the number, most people don't know...The key things to understand about a float is that it is a variable that is 32 bits long and that a number with decimals can be stored in it. so the float() would return a float number

on your specific function : float = add(3,7); you will get 10.0 if you did the same with out using float you would get : 10