#!/usr/local/bin/perl
@cards = qw(king queen king);
@swaps = (0,1,2,1,0,1);
print "The cards are ";
foreach $cards (@cards) {
print "$card\n";
}
foreach $swaps (@swaps) {
@cards = ("king" x 3);
$cards[$swaps] = "queen";
print "Now the cards are ";
foreach $cards (@cards) {
print "$card\n";
}
}
By show all working it means, in between outputs, show how the array changes. Now, what do people think the output is from the script (without running it)?
Please note that this is an exam that I have ALREADY taken, not a request to help me with coursework. Just wondering how other people answer this question, and I will explain why, after I get a couple of answers!
Thanks,
Stuart
[Edit: Formatting. GDNet tags are all-lowercase.]
[edited by - Oluseyi on May 16, 2003 4:13:55 PM]
Exam
I am not long out of an exam, for my University module, Web Programming and E-commerce. The first question was this:
Analyse the following Perl script and determine its output (please show all working).
25 views, and not a single person can tell me what the script does? The reason I asked, was because as I stated before that question was in my recent exam. There are a number of mistakes in it, that I do not believe were supposed to be there. For example in the block of code:
It is obvious that this will simply take a number of new lines equal to the length of the array. Now, SURELY in an exam, trying to trick people out of marks by misspelling $cards to $card is not fair, and therefore whoever wrote this question CLEARLY hadn''t executed the script. Which brings me onto the second thing I assume was a mistake in the code:
Now again, this line clearly set element 0 of the array to have the value "kingkingking". However, based on the fact that other parts of the script are wrong, and that it seems likely that this should have actually been:
I emailed my lecturer with a complaint about the question. Now, I feel (not meaning to sound big headed) that I am one of the top few students in my year, and that a lot of people would have been really tripped up by these mistakes. I personally chose to reinterpret the question, as though the mistakes are corrected, because I thought it was likely that what I have written down as my answer would have been the answer that was expected.
The reason I posted this question was to see how other people would react if they were given a question like this, and what answer they would have given.
So, anyone able to comment about this question now?
Thanks
Stuart
foreach $cards (@cards) { print "$card\n";}
It is obvious that this will simply take a number of new lines equal to the length of the array. Now, SURELY in an exam, trying to trick people out of marks by misspelling $cards to $card is not fair, and therefore whoever wrote this question CLEARLY hadn''t executed the script. Which brings me onto the second thing I assume was a mistake in the code:
@cards = ("king" x 3);
Now again, this line clearly set element 0 of the array to have the value "kingkingking". However, based on the fact that other parts of the script are wrong, and that it seems likely that this should have actually been:
@cards = ("king", "king", "king");
I emailed my lecturer with a complaint about the question. Now, I feel (not meaning to sound big headed) that I am one of the top few students in my year, and that a lot of people would have been really tripped up by these mistakes. I personally chose to reinterpret the question, as though the mistakes are corrected, because I thought it was likely that what I have written down as my answer would have been the answer that was expected.
The reason I posted this question was to see how other people would react if they were given a question like this, and what answer they would have given.
So, anyone able to comment about this question now?
Thanks
Stuart
If you felt the question was wrong why didn''t you ask for a clarification during the exam? That''s what the exam supervisor is there for. Doing so would have given you and everyone else in your class a clear interpretation of the questions. As it stands, you didn''t answer the question that was asked, and may therefore be legitimately penalized.
As for why people haven''t responded to the thread, realize that we''re not obliged to. If this is what a "Web Programming and E-Commerce" exam looks like, then you''ve got a long way to go due to the simplicity of the question. Besides, your interpreter is the final arbiter of what the code does, not one of us.
As for why people haven''t responded to the thread, realize that we''re not obliged to. If this is what a "Web Programming and E-Commerce" exam looks like, then you''ve got a long way to go due to the simplicity of the question. Besides, your interpreter is the final arbiter of what the code does, not one of us.
At my university, the lecturer only needs to be there for the start of the exam. So by the time I was ready to answer the question he was unavailable, and the only people there were invigilators, who would have known nothing about perl. Therefore, I needed to make a judgement as to how to answer the question, which was clearly ill thought out, and more importantly had NOT been tested. I simply wanted to know what people on these boards (whom a lot of I would consider experts) thought about this question, and whether or not I would be fair in my evaluation that it was designed to confuse, or not tested.
Either way, I realise that people are not obliged to respond to my post, and the reason behind my second post, is because I assumed that people may have thought this was a ''homework'' question and decided that they should ignore it, so I felt explaining myself was necessary.
And as for insinuating that I ''have a long way to go'' based on the simplicity of the question, I find insulting. I may not be the greatest coder on the planet, but I am by no means the worst, and this question does not reflect my ability, just the knowledge that I am required to know for the exam.
Anyway, I realise that after this post, no one will respond, so, do feel free to close the thread.
Thanks,
Stuart
Either way, I realise that people are not obliged to respond to my post, and the reason behind my second post, is because I assumed that people may have thought this was a ''homework'' question and decided that they should ignore it, so I felt explaining myself was necessary.
And as for insinuating that I ''have a long way to go'' based on the simplicity of the question, I find insulting. I may not be the greatest coder on the planet, but I am by no means the worst, and this question does not reflect my ability, just the knowledge that I am required to know for the exam.
Anyway, I realise that after this post, no one will respond, so, do feel free to close the thread.
Thanks,
Stuart
quote:They could have noted the confusion over the intent of the question in their exam report, which would affect the grading of student answers. It never hurts to ask.
Original post by stustill
At my university, the lecturer only needs to be there for the start of the exam. So by the time I was ready to answer the question he was unavailable, and the only people there were invigilators, who would have known nothing about perl.
quote:You had sufficiently indicated that it wasn''t homework but a review of an exam you had already had. Sometimes you have to be patient. The 25 people who viewed your thread (I did) may not have been as proficient in Perl as they are in other technologies. For example I''m no longer on top of my Perl, not having used it in about 3 years.
Either way, I realise that people are not obliged to respond to my post, and the reason behind my second post, is because I assumed that people may have thought this was a ''homework'' question and decided that they should ignore it, so I felt explaining myself was necessary.
quote:Silly child, it''s not you I was referring to. It''s the idea that an institution will hype a course with a name like "Web Programming and E-Commerce", but only test simple list context functionality at the end of a semester. I think you''d agree that the question in reference was pre-midterm difficulty. I realize that there may have been other questions that were more involved, but that''s what I said and I have to deal with the consequences of it, whatever they may be.
And as for insinuating that I ''have a long way to go'' based on the simplicity of the question, I find insulting.
quote:Why do you think no one will respond? Because you''ve been confrontational? Confrontation is a part of life! You stood up and defended your position rather than backing down and cowering (perhaps because I''m the forum mod). For doing so, I now respect you!
Anyway, I realise that after this post, no one will respond, so, do feel free to close the thread.
Thread stays, in case anyone has anything to contribute. Cheers!
Sorry, took what you said the wrong way, I think what you wrote can be taken to be insulting if you read it in way I did! Anyway, I did actually email the lecturer quite a long email (which I can post if anyone wants to read it), describing my feelings to the question. A lot of other people on the course simply could not answer that question (they don''t want to be programmers), so they are quite pleased about my email.
Anyway, my course isn''t actually ''Web programming and e-commerce'', that is just one of the modules I am required to do. I am actually doing a Computer Science degree, and I have a fun Operating Systems exam on Monday morning Wish me luck!
Ohh, and I did look at the nice red text beneath your name just before I sent my last post!
Stu
Anyway, my course isn''t actually ''Web programming and e-commerce'', that is just one of the modules I am required to do. I am actually doing a Computer Science degree, and I have a fun Operating Systems exam on Monday morning Wish me luck!
Ohh, and I did look at the nice red text beneath your name just before I sent my last post!
Stu
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement