Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Reviewing Functions

Iniubong Etuk
Iniubong Etuk
2,634 Points

I'm not sure what the correct answer is to this quiz

what will this code print out? I dont think I understood the video really well

1 Answer

nick schubert
nick schubert
3,535 Points

Question one asks what could be done to fix the duplication of the code. You see the following code:

first_number = 5
first_result = first_number * first_number
print("The number {} squared is {}".format(first_number, first_result))

second_number = 8
second_result = second_number * second_number
print("The number {} squared is {}".format(second_number, second_result))

You can see that both blocks of code are doing the same thing, which is dry code. You don't want to keep on writing the same code over and over again. So, writing a function that does exactly this will help you.

I hope this clears it up for you!