Troubleshooting math with strings

ok, I started organising this slightly differently than the exercise intended:

How many squares for 6 people to have 6 quilts each that are 6x6?

people=‘6’
print(‘number of people:’)
print(people)

number_of_quilts=‘6’
print(‘no of quilts:’)
print(number_of_quilts)

quilt_tiles=‘6’
print(‘no of tiles:’)
print(quilt_tiles)

qt_per_blanket=(‘quilt_tiles’ ** 2)
print(qt_per_blanket)

total_tiles=(‘people’ * ‘number_of_quilts’ * ‘qt_per_blanket’)
print(total_tiles)

now i’m getting errors on those last two outputs i’m trying to generate. what am i doing wrong?:

number of people:
6
no of quilts:
6
no of tiles:
6
Traceback (most recent call last):
File “script.py”, line 25, in
qt_per_blanket=(‘quilt_tiles’ ** 2)
TypeError: unsupported operand type(s) for ** or pow(): ‘str’ and ‘int’

did you also read that error? they’re for reading. your error says something about what operation isn’t possible. do you think it should be? reconsidering what you meant and what operations are available, that’s how you figure out what to change

how far do you get in this reasoning? based on what you’ve said so far, the next thing to do is to read the error message. what do you know about the problem, and what information are you missing to fix it?

i did, but it means nothing to me at the moment. complete babe in the woods.

the exercise just wants me to put ‘6 ** 4’ and move on.

but before i realised that i was trying to organise it step by step. my issue is i obviously don’t know enough about basic variables and how to create a new variable referencing the existing ones multiplied together.

so i’m ready to abandon what i’ve done so far but was just interested in seeing how it would look if someone who knew what they were doing did it with the (superflous) steps i have.

that’s fine, but that’s still the route to go through. that starts with identifying the roadblocks, that’s what you probably should be asking about. in this case, it’s interpreting the error message.

the error message says you use an operator and two values. which is the operator, and which are the two types, and do you think the operator is meaningful for those types? and do you agree that this is what your code is indeed doing, and is that what you meant to write and if so what meaning would you argue it has?

qt_per_blanket = quilt_tiles ** 2
print(qt_per_blanket)

total_tiles = people * number_of_quilts * qt_per_blanket
print(total_tiles)

can you see what i’m trying to do with i’ve posted?

just formated the output to show the factors im working with, 6 people, 6 quilts

create a new variable using those first two factors together to get area, tiles = 6x6

create a total area of whole order 6x6x6x6

obviously i don’t know correct syntax yet, i tried adding spaces and brackets and print in different places.

don’t know the lingo yet, probably best i move on and figure this out when i bit more au fait with correct variable use.

Whenever you put something within quotes, you’re saying THESE LETTERS

'lettuce' l-e-t-t-u-c-e
'65' 6-5

Like a list of letters:

['l', 'e', 't', 't', 'u', 'c', 'e']
it speaks of those letters and has no further meaning.

You would only do this for text.
numbers are not represented as text, and if you want to refer to a variable then you wouldn’t mention the text matching the name of the variable.

So if that’s what literal text looks like, what does a literal number look like? Given some of those you could get some math operations to happen.

ah ok, so i was using ’ ’ all over the shop! so with some changes:

people=6
print(‘number of people:’)
print(people)

number_of_quilts=6
print(‘no of quilts:’)
print(number_of_quilts)

quilt_tiles=6
print(‘no of tiles:’)
print(quilt_tiles)

qt_per_blanket= quilt_tiles ** 2
print(‘qt_per_blanket:’)
print(qt_per_blanket)

total_tiles= people * number_of_quilts * qt_per_blanket
print(‘total_tiles:’)
print(total_tiles)

that has given me what i intended:

number of people:
6
no of quilts:
6
no of tiles:
6
qt_per_blanket:
36
total_tiles:
1296

thanks, for the clarification.