count = 10
sum = 0
average = 0.0
for i in range(0, count):
print "Enter a grade: ",
grade = int(raw_input())
sum += grade
average = sum/count
print "Average of the ten grades entered is: ", average
sum = 0
average = 0.0
print "Enter the first five grades: "
grade0 = int(raw_input("grade0: "))
grade1 = int(raw_input("grade1: "))
grade2 = int(raw_input("grade2: "))
grade3 = int(raw_input("grade3: "))
grade4 = int(raw_input("grade4: "))
print "Enter the last five numbers in the same manner "
grade5 = int(raw_input("grade5: "))
grade6 = int(raw_input("grade6: "))
grade7 = int(raw_input("grade7: "))
grade8 = int(raw_input("grade8: "))
grade9 = int(raw_input("grade9: "))
sum = grade0 + grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8 + grade9
average = sum/10
print "Average of the ten grades entered is: ", average
grades = []
count = 10
sum = 0
average = 0.0
print "Enter the 10 grades: "
for i in range(0, count):
print "%2d> " %(i + 1),
grades.append(int(raw_input()))
sum += grades[i]
average = sum/count;
print "Average of the ten grades entered is: ", average
grades = []
count = 10
sum = 0
average = 0.0
print "Enter the 10 grades: "
for i in range(0, count):
print "%2d> " %(i + 1),
grades.append(int(raw_input()))
sum += grades[i]
average = sum/count;
for i in range(0, count):
print "Grade Number %2d is %3d" %(i + 1, grades[i])
print "Average of the ten grades entered is: ", average
import sys
a = 1
b = 2
c = 3
d = 4.0
e = 5.0
f = 6.0
print "A variable of type integer occupies %d bytes." %sys.getsizeof(int)
print "Here are the addresses of some variables of type integer:"
print "The address of a is: %d The address of b is: %d" %(id(a), id(b))
print "The address of c is: %d" % id(c)
print "A variable of type float occupies %d bytes." %sys.getsizeof(float)
print "Here are the addresses of some variables of type float: "
print "The address of d is: %d The address of e is: %d" %(id(d), id(e))
print "The address of f is: ", id(f)
size = [['6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7'],
['1', '5', '3', '7', ' ', '1', '1', '3', '1', '5', '3', '7'],
['2', '8', '4', '8', ' ', '8', '4', '8', '2', '8', '4', '8']]
headsize = [164, 166, 169, 172, 175, 178, 181, 184, 188, 191, 194, 197]
hat_found = False
print "Enter the circumference of your head above your eyebrows in inches as a decimal value: ",
cranium = float(raw_input())
your_head = int(8.0*cranium)
i = 0
if(your_head == headsize[i]):
hat_found = True
else:
for i in range(1, len(headsize)):
if(your_head > headsize[i - 1] and your_head <= headsize[i]):
hat_found = True
break
if(hat_found):
print "Your hat size is %c %c%c%c" %(size[0][i], size[1][i], ' ' if (size[1][i]==' ') else '/', size[2][i])
else:
if(your_head < headsize[0]):
print "You are the proverbial pinhead. No hat for you I'm afraid."
else:
print "You, in technical parlance, are a fathead, No hat for you, I'm afraid."
print "Enter the number of grades: ",
nGrades = int(raw_input())
grades = []
sum = 0
print "Enter the %d grades: " % nGrades
for i in range(0, nGrades):
print "%d> " %(i + 1),
grades.append(int(raw_input()))
sum += grades[i]
print "The grades you entered are: "
for i in range(0, nGrades):
print "Grade[%d] = %d " %((i + 1), grades[i]),
if((i+1) % 5 == 0):
print "\n"
average = sum/nGrades
print "Average of the %d grades entered is: %.2f" %(nGrades, average)
player = 0
winner = 0
choice = 0
row = 0
column = 0
board = [['1','2','3'],
['4','5','6'],
['7','8','9']]
i = 0
while(i < 9 and winner == 0):
print "\n"
print " %c | %c | %c" %(board[0][0], board[0][1], board[0][2])
print "---+---+---"
print " %c | %c | %c" %(board[1][0], board[1][1], board[1][2])
print "---+---+---"
print " %c | %c | %c" %(board[2][0], board[2][1], board[2][2])
player = i % 2 + 1
while(choice < 0 or choice > 8 or board[row][column] > '9'):
print "Player %d, please enter a valid square number for where you want to place your %c: " %(player,'X' if (player == 1) else 'O')
choice = int(raw_input())
choice = choice - 1
row = choice/3
column = choice % 3
board[row][column] = 'X' if (player == 1) else 'O'
if((board[0][0]==board[1][1] and board[0][0]==board[2][2]) or (board[0][2]==board[1][1] and board[0][2]==board[2][0])):
winner = player
else:
for line in range(0, 3):
if((board[line][0] == board[line][1] and board[line][0] == board[line][2]) or (board[0][line] == board[1][line] and board[0][line] == board[2][line])):
winner = player
i += 1
print "\n"
print " %c | %c | %c" %(board[0][0], board[0][1], board[0][2])
print "---+---+---"
print " %c | %c | %c" %(board[1][0], board[1][1], board[1][2])
print "---+---+---"
print " %c | %c | %c" %(board[2][0], board[2][1], board[2][2])
if(winner):
print "Congratulations, player %d, YOU ARE THE WINNER!" % winner
else:
print "How boring, it is a draw"