RE: Python Programming For Beginners Lesson 3 - User Input
You're welcome!
I agree, I'm looking around searching for fellow developers, that's how I stumbled upon you.
I will thanks, you too!
I have one quick question if you don't mind me asking - I haven't used Python in ages, I'm just curious about something. Because Python is dynamically typed language, if user wanted to input some number, you'd need to cast it/convert it to int/float before storing in variable, correct?
I mean, especially if you wanted to do some arithmetic with such stored number later, I'm sure by default Python could store number as a string and display it properly by default.
If so, that might be something you could also add (think name + age), given that strings and numbers are two most commonly used basic data types. But it's nice and short tutorial as is, so that's just one suggestion because you were asking for some
Yes, you are correct, so if you wanted to store an integer in a variable using the input function you would do something like this
num = int(input("Enter a number: "))
or you could do this, the number will be stored as a string until you wish to use itprint(int(num) + 5)
.I appreciate the suggestion and I do have number input planned for the next lesson where I will be looking at operators and creating a very simple calculator program. This lesson was kind of the setup for that one so that I don't have to cover too much information in just one lesson.
Thanks for the feedback
Thanks for clarifying that.
Actually your comment is so succinct and nice that you can "pretty much" copy and paste it into your post above, heh.
But yeah if you've planned that already, do like you intended to - I just wanted to give you feedback! You're welcome fellow developer!