You are viewing a single thread.
View all comments
11 points

I wonder if day length is given separately in a table prior to the question? I’m not sure what they wanted except maybe seconds?

permalink
report
reply
106 points

It’s the length of the string. The number of characters is 6. It’s a play on words and a question.

permalink
report
parent
reply
15 points

Oh wow. Thanks

permalink
report
parent
reply
-12 points

I’m not really a fan of this kind of question. Especially if there’s enough questions that time will be an issue for most. Because at first glance it’s easy to think the answer might be the length of a day.

There shouldn’t be a need to try to trick people into the wrong answer on an open question. Maybe with multiple choice but not an open answer question.

permalink
report
parent
reply
23 points

It relies on critical thinking (meaning thinking about your own thinking), basically, and most students aren’t very good at that.

permalink
report
parent
reply
19 points

I get your point about it being a trick question but I think in this case it’s pretty reasonable that you would see code like this in real life. Where the programming metaphor and your understanding of the real world clash. It’s a very important skill to be able to spot the difference.

permalink
report
parent
reply
4 points

Software engineering as a discipline is pretty much a series of trick questions.

permalink
report
parent
reply
29 points

I’m assuming they wanted the literal length of the string

permalink
report
parent
reply
11 points

That seems to be the consensus.

permalink
report
parent
reply
1 point

Naw, they wanted the metaphorical length. Computers are great at metaphors.

permalink
report
parent
reply
19 points

Conversations about language aside, the error is that “Monday” is a string with a length of 6.

permalink
report
parent
reply
4 points

What is the type of the variable day though? As it is we have to make multiple assumptions, based on popular programming languages, about the internals of the string type and the print function to assume that it prints “6”.

permalink
report
parent
reply
9 points

There is a fairly good chance that there has been more info presented in the class than we have been given here.

permalink
report
parent
reply
3 points
Deleted by creator
permalink
report
parent
reply
1 point

That’s the variable name, not the type

permalink
report
parent
reply
-7 points
*

Most date libraries count to 23h 59m 59s then roll over to 00h 00m 00s. So the answer is 23 hours, not 24.

Edit: I’m big dum dum. It’s asking string length of “Monday”, thus 6.

permalink
report
parent
reply
22 points

You’re also mistaken about the time too. The first second of the day is 00:00:00 the last second of the day is 23:59:59

That’s still a full and exact 24 hours.

permalink
report
parent
reply
9 points

Yes, it’s a full 24 hours, but a library doesn’t use 24:00:00 to represent the last hour, it’s 23:59:59. Once it hits 24:00, it rolls over to 00:00:00.

Hence my initial error of answering 23.

It’s not valid, but I don’t edit out erronous answers because I believe all data should be preserved, no matter how dumb it makes one look.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 5.2K

    Monthly active users

  • 1K

    Posts

  • 38K

    Comments