Westonci.ca connects you with experts who provide insightful answers to your questions. Join us today and start learning! Experience the convenience of finding accurate answers to your questions from knowledgeable professionals on our platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

Do you think we could use mathematical operators on string values rather than integers or floats? Explain.


Sagot :

Answer:

Yes and no. For example, you can do this:

print('hi' * 5)

Output:

hihihihihi

HOWEVER, you cannot do mathematical operations on strings. If I have a string "6" and try dividing it by 3, it's not going to work because... it's not an integer. While multiplying strings does work, you cannot actually do real math with strings unless you change them to int or float