Hey there its me again i got this program but i have to improve on it but i am stuck hopefully you can help here is the code
[CODE=python]
def student():
welcome();
info = [ ]
print "Creating a file studentHND.txt to write to: \n";
output = open("studentHN D.txt","w");
for i in range(5):
name = raw_input('Plea se enter name: ');
python = validate('Pleas e enter mark for pythod: ');
aandd = validate('Pleas e enter mark for aandd: ');
learn = validate('Pleas e enter mark for learn: ');
info.append(nam e)
info.append(pyt hon)
info.append(aan dd)
info.append(lea rn)
output.write(st r(name)+','),ou tput.write(str( python)+'in PYTHOD,'),outpu t.write(str(aan dd)+'in AANDD,'), 'and',output.wr ite(str(learn)+ 'in Learn'),"\n";
print "\nOperatio n complete"
output.close();
def validate(prompt ):
limit = input(prompt);
while(True):
if (limit>=0 and limit<=100):
return limit;
else:
print limit, "invalid"
limit = input(prompt);
def welcome():
print "This program opens and write information into a file"
print '************** *************** *************** *************** ******'
[/CODE]
Basically to improve on it i have to wirte a program which records data from the file created in the above exercise and it should calculate and print out the following:
the name of each student, and which units, if any, they failed(ie a mark under 40). If they failed nothing i should report that as well.
the average score for each unit and which unit achieved the highest average
Thanks
[CODE=python]
def student():
welcome();
info = [ ]
print "Creating a file studentHND.txt to write to: \n";
output = open("studentHN D.txt","w");
for i in range(5):
name = raw_input('Plea se enter name: ');
python = validate('Pleas e enter mark for pythod: ');
aandd = validate('Pleas e enter mark for aandd: ');
learn = validate('Pleas e enter mark for learn: ');
info.append(nam e)
info.append(pyt hon)
info.append(aan dd)
info.append(lea rn)
output.write(st r(name)+','),ou tput.write(str( python)+'in PYTHOD,'),outpu t.write(str(aan dd)+'in AANDD,'), 'and',output.wr ite(str(learn)+ 'in Learn'),"\n";
print "\nOperatio n complete"
output.close();
def validate(prompt ):
limit = input(prompt);
while(True):
if (limit>=0 and limit<=100):
return limit;
else:
print limit, "invalid"
limit = input(prompt);
def welcome():
print "This program opens and write information into a file"
print '************** *************** *************** *************** ******'
[/CODE]
Basically to improve on it i have to wirte a program which records data from the file created in the above exercise and it should calculate and print out the following:
the name of each student, and which units, if any, they failed(ie a mark under 40). If they failed nothing i should report that as well.
the average score for each unit and which unit achieved the highest average
Thanks
Comment