examResult.py源代码分析

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

# Fig. 3.15: fig03_15.py

# Analysis of examination results.

# initialize variables

passes = 0 # number of passes

failures = 0 # number of failures

studentCounter = 1 # student counter

# process 10 students; counter-controlled loop

while studentCounter <= 10:

result = raw_input( "Enter result (1=pass,2=fail): " )

%输入两个值,1代表通过,2代表不及格

result = int( result ) # one exam result

%转化为int型

if result == 1:

passes = passes + 1

%如果result为1,则通过的个数加1

else:

failures = failures + 1

%如果result为0,则失败数加1

studentCounter = studentCounter + 1

%计数器加一

# termination phase

print "Passed", passes

%打印通过的个数

print "Failed", failures

%打印失败的个数

if passes > 8:

print "Raise tuition"

%如果通过率超过0.8,则提高本门课程的学费

你可能感兴趣的:(C++,c,C#)