So I’ve been leaning python for almost a year now, and thoughts it would be nice to refresh my knowledge a little.
The one thing I found odd so far was how the course mentions how you can’t put numbers inside a string.
It’s mentioned under 5. Datatypes & Typecasting.
I did just that.
print(“Can I write words and numbers?”)
print(“testing 123. Test 1 2 3”)
Output
Can I write words and numbers?
testing 123. Test 1 2 3
Did that in Atom and in Python vai Powershell with no errors.
Can someone explain why the course says I can’t do something I did?
In case I’ve made a giant blunder I apologize, still learning.
It’s not a number as in something of the type of number, it’s just the character representing a number. "number 2"
is just a string, same as "number two"
, you can’t do calculations with it. "1 + 2"
is like "one + two"
, not like 1 + 2
. I don’t know the course, but I assume that’s all it’s saying.
I’m aware that when you put a number between two " " the number is viewed as a string in python and is unusable for math operations.
Could be that my brain thinks more “creatively” during the late hours of the day, and I see things from a beginners perspective.
I’ll post a link of the curse below so you can see for yourself.
Python is a popular, versatile and easy-to-learn language. It's the go-to
language for AI, Machine Learning and Data Science. Some say it's also the
easiest programming language to get started with.
If this sounds like a programming language you...
I’ve read the idiosyncrasies regarding typecasting and I understand them, it’s just that I wrote this post to get a 2nd opinion on the matter.
Thank you for your reply