how could i write my code?

Hello..
what is the best form to write my code
shall i print a result as a test in the end of the code? or maybe more results?
shall i put comments to explain?
shall i put more strings as a style?
please i need a guide to write my code as well because everybody needs time to solve HM so it will be bad if he/she got zero after all that..
Thanks a lot
Shazly Ahmed

asked 03 Mar '12, 11:24

Shazly%20Magdy%20Mohamed%20Ahme-2's gravatar image

Shazly Magdy...
12719
accept rate: 0%

retagged 03 Mar '12, 11:32

Ulquiomaru's gravatar image

Ulquiomaru
2.3k11846


3 Answers:

Some guidelines:

  • Comments: the grading bot doesn't read them, but they will be useful for you when you review your code later.

  • Output: If you're asked to print a number, print only the number, don't add any text (like "The answer is:"). If you're asked to print a string, then print strictly what is needed and nothing else. Check for tips inside the default comments, like # Make sure your procedure has a return statement.

  • Leave professor's code as it is: Don't delete any comments left by the professor. And read them twice.

  • Debugging and testing: If you need to use the print command to see how you're doing, or test your output, don't forget to delete or comment them before submitting your code. Printing more than asked, even for testing, will get you a Incorrect grade.

  • If you want to be really clean, before submitting, copy your final code, click reset to have a pristine version of the question's professor's code and then paste where appropriate, run one time and submit.

link
This answer is marked "community wiki".

answered 03 Mar '12, 11:51

Adriana%20Villafa%C3%B1e-4's gravatar image

Adriana Vill...
2751312

edited 03 Mar '12, 11:55

Olivier%20GERARD's gravatar image

Olivier GERARD
2.2k122856

Nicely done.

(03 Mar '12, 17:35) PeterUdacity ♦♦ PeterUdacity's gravatar image

You have to pay great attention to the text of the exercise...there is not a fixed pattern...

link

answered 03 Mar '12, 11:28

Lele's gravatar image

Lele
2.7k31534

Code is graded by a bot so no point in adding comments unless you're just using them to keep you on track. Don't print out anything more than the question asks for, this will cause the bot to think you printed the wrong answer. I try to write my code so that it gets the job done and nothing more. If I use print statements to test or debug my output, I remove them before I submit my final answer. Keep it simple.

link

answered 03 Mar '12, 11:30

turboyoshi's gravatar image

turboyoshi
311110

do I understand this correctly this bot does a print statement to see if the code works ???

(03 Mar '12, 11:54) annem1eke annem1eke's gravatar image
Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,299
×1,718
×195
×12
×9
×7

Asked: 03 Mar '12, 11:24

Seen: 292 times

Last updated: 03 Mar '12, 17:35