FAQ: Learn Python: Syntax - Changing Numbers

This community-built FAQ covers the “Changing Numbers” exercise from the lesson “Learn Python: Syntax”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Changing Numbers

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

1 Like

9 posts were split to a new topic: How can I print a sentence with the calculation?

3 posts were split to a new topic: Why doesn’t my sum update?

2 posts were split to a new topic: I found a bug in python 3 changing numbers? [resolved]

A post was split to a new topic: I don’t understand the question?

2 posts were merged into an existing topic: How can I print a sentence with the calculation?

2 posts were merged into an existing topic: What happens when you are updating the value of some variable?

There is 2 ways to concatenate integer with string in python:

#(1) print(“The number of square needed”, number_of_squares)
adding a comma in between the variable and the string will allow you concatenate them with out error

#(2)
adding a f {short cut for formate} at the beginning of the sentence out side of the paretics like this

print(f"The number of square needed {number_of_squares}")

In a different python course, it said the last line of code was automatically outputted without having to use a print() statement. Why is that not the case in this excercise?

Do you have the original source for this? Context is missing. That could have applied to the python IDLE maybe.

I have trouble understanding the context. The 1st task says, " To calculate the number of squares you’ll need for your first quilt let’s create two variables: quilt_width and quilt_length . Let’s make this first quilt 8 squares wide and 12 squares long."

Although the answer is the product of the two, but, doesn’t it tell us the area of the quilt? If we know the area of each individual squares, then the number of squares can easily be found out by dividing the former by the latter, right? Can anyone tell me what point I’m missing?

I don’t think the exercise uses a specific system of measurement so you’re just relying on the standard area = width * length for a rectangle. You could say you’re using ‘squares’ as your unit (instead of square centimetre, square foot etc.) if that reads a little better to you.

Oh! So, the number of squares is not the actual square shapes in the quilt, but rather the square ‘units’ (from the product of length and width)? I got confused by the usual image of a quilt having different square fabrics. Thank you.

1 Like

On the changing numbers lesson. I assign two separate values to two separate variables

variable_1 = 5
variable_2 = 10

I assign the product of these two variables to a newly declared variable

variable_product = variable_1 * variable_2

I print variable_product and get the proper output (in this case 50).
I update variable_2 to 5 two lines below the print(variable_product) string I just processed.

#prints 50
print(variable_product)

variable_2 = 5

I print variable_2 to see if the update worked and it prints 5.
I reprint the variable_product but instead of outputting the value 25 it maintains its old output (50) in which case variable_2 = 10 and not the newly updated 5.
What am I doing wrong?
If I rewrite variable_product = variable_1 * variable_2 on the line above the second print(variable_product) then it outputs 25, but I can see how that would be counter-productive at times. Thank you for any help in advance.

Maybe I’m jumping the gun and assuming this works like JS.

For a very brief introduction see- What happens when you are updating the value of some variable?

More generally you could have a web search for how python passes objects around, something like the following may help but there’s quite a lot of discussion on it around the web-

for this problem: ‘quilt_width’ is an invalid keyword argument for this function. i already ths the keyword and variable why is it not working?

Silly or laziness question. Wouldn’t be easier or practical to just change the quilt_length number from “12” to “8” to satisfy intrusction #3, instead of adding additional lines as it shows in the walkthrough video?