Sep. 22, 2012

Python Code: Calculate the average score

Overview

This script will calculate the average of three values. 

Make sure to put in "int" before the raw_input function, since we are
using integers.

# Get three test score
round1 = int(raw_input("Enter score for round 1: "))

round2 = int(raw_input("Enter score for round 2: "))

round3 = int(raw_input("Enter score for round 3: "))
   
# Calculate the average
average = (round1 + round2 + round3) / 3

# Print out the test score
print "the average score is: ", average 
Happy Scripting

Recommended Python Training – DataCamp

For Python training, our top recommendation is DataCamp.

Datacamp provides online interactive courses that combine interactive coding challenges with videos from top instructors in the field.

Datacamp has beginner to advanced Python training that programmers of all levels benefit from.

 



Read more about:
Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, PythonForBeginners.com only recommend products or services that we try personally and believe will add value to our readers.