辅导案例-M304/GG44

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CHEM 3344/M304/GG44 numerical and analytical methods – Module 2: Programming Guide

1

An Acceptable Program should:
o Be written in Python3
o Compile without error
o Do what was asked in question and provide ‘correct’ answers
o Answers should be printed out so they can be viewed
It should not be necessary to use debugging and break points to check values
o Outputs should be clear, give units and indicate what the results are
o If Inputs are required it should be clear where to enter them and what units are expected
o Hard coding of calculations should be minimised where possible
For example:
atm = 12 * 1.6605402E-27
print("Compare ease of adapting this")
print("Carbon atom mass 12 amu = ")
print(str(atm) + " kg")
print("To this")

atom_unit = 1.6605402E-27

atom_mass = 12 #enter mass here

atm = atom_mass * atom_unit

print("Atom of mass" + str(atom_mass) + " amu = " + str(atm) + " kg")
print("The last method is more adapatable")


o Repetitive code should be replaced with loops and functions where possible/sensible.
For example:
print("Compare this output ... ")

print("1")
print("2")
print("3")
print("4")
print("5")
print("6")
print("7")
print("8")
print("9")
print("10")

print(".. to this")

for x in range(10):
print(x+1)

print("Which has simpler code")
CHEM 3344/M304/GG44 numerical and analytical methods – Module 2: Programming Guide

2

Best Practise (in my opinion)
Minimise number of variables and their size
Write code to make it reusable and adaptable, for example if set up to perform calculations
on 100 numbers write it so it can be extended to 1000 or 1000,000 values with only a little work.
Build code up slowly, make sure each part works as you go. Use cout and breakpoints
liberally (they can always be commented out). For example, if coding something with nested loops
get the inner loops working first, then add the outer loops one at a time. Check to see if it breaks.
(Never run before you can walk).
Remember the Chemistry/Physics of what you are trying to calculate. Compare your results to what
you expect. Think about what you are doing.
An outline of how the programming questions are marked
Grade
Range
Grade Coding Quality
80 –
100
A* Program does everything asked of it
but goes beyond what was asked.
Use is made of more advanced
programming techniques such as
functions.
Advanced testing is shown.
Problem is solved in an exemplary
manner.
Very advanced understanding of the
problem is shown
70 – 80 A Program does everything asked of it in
question correctly.
Use is made of advanced
programming techniques such as
functions.
Evidence of testing is shown.
Given problem is solved in a complete
manner.
Deeper understanding of the problem is
shown
60 – 70 B Program is correct but is simplistic. Given problem is solved.
Understanding of the problem is shown.
50 – 60 C Program gives incorrect answers due
to a more significant error.
Program does not do everything
asked of it in question.
Program is correct but really does not
use appropriate methods.
No testing is performed.
The given problem is almost solved.
Some understanding of the problem is
shown.
40 – 50 D Program suffers from serious errors.
Program is incomplete.
The problem is not close to being solved
but progress has been made
Limited understanding of the problem is
shown.
0 – 40 E Program suffers from major errors.
Program does not compile.
The problem is not solved at all.
No understanding is shown
See above for examples of appropriate methods


欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468