Python variable question


#1

I am confused by this lesson on Python Syntax Variables. It tells us to assign a value to represent the date. I put in 5/8/2018 and it accepted it but I don’t understand why. If I had used 23473, would it still have accepted it? Does the value you put in really matter? Could someone please explain this a little further for me?


#2

Which exercise is this?

>>> import datetime
>>> datetime.date.fromtimestamp(23473)
datetime.date(1969, 12, 31)
>>> 

One way to find out would be to break it by feeding in values that might work to see if they do, and toss in some garbage to see how it is handled.

At the very least stop on this subject for a time and catch up on documentation reading and practice drills. There is quite a lot involved in this subject and it deserves extra study.


#3

@mtf Thank you for your reply. I was on lesson 5, variables.


#4

Could you post a link, please? Thanks.


#5

@mtf https://www.codecademy.com/courses/learn-python/lessons/python-syntax/exercises/variables


#6

This lesson does not appear to focus on Date and Time. Perhaps set this question aside until you reach the subject in a later unit. It’s not a good time to segue into this topic. Forge ahead and get the language under your belt so when you reach this subject you’ll be better prepared and understand more readily.


#7

@mtf Thank you for your help and advice. I will keep going and hopefully gain a better understanding. :grinning:


#8

That’s new… feb 16th
And about as stupid as it appears

I’d say the correct way to read that is that you may use any value whatsoever. (Which makes it odd that they even mention the word date)

For some unfanthomable reason the exercise won’t accept the value None but that’s not special in any way in this context, entirely arbitrary.


#9

@ionatan Thanks. I guess I was missing the purpose of the lesson. I was getting too concerned with the “date” aspect, though it doesn’t seem to really matter here. I guess if I keep going the answer will become more clear? Sounds like it is a little more complex than I thought.


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.