| #! /usr/bin/env python | |
| from stat import * | |
# Calculate the average of a series of numbers. | |
SCORE="0" | |
# Calculate the average of a series of numbers. | |
SCORE="0" | |
AVERAGE="0" | |
AVERAGE="0" | |
SUM="0" | |
SUM="0" | |
NUM="0" | |
NUM="0" | |
while true; do
echo -n "Enter your score [0-100%] ('q' for quit): "; read SCORE;
if (("$SCORE" < "0")) || (("$SCORE" > "100")); then
echo "Be serious. Common, try again: "
elif [ "$SCORE" == "q" ]; then
echo "Average rating: $AVERAGE%."
break
else
SUM=$[$SUM + $SCORE]
NUM=$[$NUM + 1]
AVERAGE=$[$SUM / $NUM]
fi
done
| |
while (True):
print("Enter your score [0-100%] ('q' for quit): ")
SCORE = raw_input()
if ("$SCORE" < "0" or "$SCORE" > "100" ):
print("Be serious. Common, try again: ")
elif (SCORE == "q" ):
print("Average rating: "+str(AVERAGE)+"%.")
break
else:
SUM=str([$SUM + $SCORE])
NUM=str([$NUM + 1])
AVERAGE=str([$SUM / $NUM]) | |
echo "Exiting." | |
print("Exiting.") | |
ÿ |