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 trialIniubong Etuk
2,634 PointsI'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
3,535 PointsQuestion 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!