#!/usr/bin/env python# -*- coding: utf-8 -*-class Aluno: def __init__(self,nome,serie): self.nome=str.capitalize(nome) self.serie=serie #Definição das notas de português nota1=[0,0,0,0] media1=0 def portugues(self,sem,nota1): self.nota1[sem]=nota1 def mediapor(self): Notas = 0 Media = 0 i = 0 while (i < 4): Notas += self.nota1[i] i += 1 Media = Notas / 4 return Media #Definição das notas de matematica nota2=[0,0,0,0] def matematica(self,sem,nota2): self.nota2[sem]=nota2 def mediamat(self): Notas = 0 Media = 0 i = 0 while (i < 4): Notas += self.nota2[i] i += 1 Media = Notas / 4 return Media #Definição das notas de ciências nota3=[0,0,0,0] def ciencias(self,sem,nota3): self.nota3[sem]=nota3 def mediacie(self): Notas = 0 Media = 0 i = 0 while (i < 4): Notas += self.nota3[i] i += 1 Media = Notas / 4 return MediaNome=raw_input('Digite o nome do aluno: ')Serie=raw_input('Digite a série do aluno: ')aluno=Aluno(Nome,Serie)#Escolha das notas#Portuguesprint '\n\nNotas de português'for i in range(4): conf=1 nota=0.0 while conf==1: nota=float(raw_input('Digite a nota do %sº bimestre: '%str(i+1))) if nota<=10.0: conf=0 aluno.portugues(sem=i,nota1=nota) i+=1 else: print 'A nota digitada deve ser entre 0 e 10, digite novamente.'#Matematicaprint '\nNotas de matemática'for i in range(4): conf=1 while conf==1: nota=float(raw_input('Digite a nota do %sº bimestre: '%str(i+1))) if nota<=10.0: conf=0 aluno.matematica(sem=i,nota2=nota) i+=1 else: print 'A nota digitada deve ser entre 0 e 10, digite novamente.'#Cienciasprint '\nNotas de ciências'for i in range(4): conf=1 while conf==1: nota=float(raw_input('Digite a nota do %sº bimestre: '%str(i+1))) if nota<=10.0: conf=0 aluno.ciencias(sem=i,nota3=nota) i+=1 else: print 'A nota digitada deve ser entre 0 e 10, digite novamente.'html=open('boletim.html','w')html.write('<html>\n<head>\n<title>Boletim - '+aluno.nome+'</title>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n')#Apply CSS Stylehtml.write("""<style type="text/css"><!--body { margin: 10; padding: 10; font: 80% Verdana, Lucida, sans-serif; color: #333366;}h1 { margin: 0; padding: 0; font: 200% Lucida, Verdana, sans-serif;}a{ color: #436976; text-decoration: none;} a:hover { background: #c4cded; text-decoration: underline; } table { margin: 1em 0em 1em 0em; border-collapse: collapse; border-left: 1px solid #858ba1; border-bottom: 1px solid #858ba1; font: 90% Verdana, Lucida, sans-serif; } table th { padding: 0em 1em 0em 1em; border-top: 1px solid #858ba1; border-bottom: 1px solid #858ba1; border-right: 1px solid #858ba1; background: #c4cded; font-weight: normal; } table td { padding: 0em 1em 0em 1em; border-top: 1px solid #858ba1; border-right: 1px solid #858ba1; text-align: center; } form { margin: 0; border: none; } input { border: 1px solid #858ba1; background-color: #c4cded; vertical-align: middle; } --> </style> </head> <body>""")html.write('<h1>Notas do(a) aluno(a) '+aluno.nome+' da '+str.strip(aluno.serie)+'ª série</h1>\n')######################################html.write('<table border="1" cellpadding="3" cellspacing="0">\n<tbody>\n')html.write('<tr>\n')html.write('<td><b>Português</b></td>\n')for i in aluno.nota1: html.write('<td>') if i<5.0: html.write('<font color="red">') i=str(i) html.write(str.strip(i)) if float(i)<5.0: html.write('</font>') html.write('</td>\n')#media 1#############################html.write('<td>')mediap=aluno.mediapor()if mediap<5.0: html.write('<font color="red">')mediap=str(mediap)html.write('<b>Média: </b>'+str.strip(mediap))if float(mediap)<5.0: html.write('</font>')html.write('</td>\n')html.write('</tr>')#####################################html.write('<tr>\n')html.write('<td><b>Matemática</b></td>\n')for i in aluno.nota2: html.write('<td>') if i<5.0: html.write('<font color="red">') i=str(i) html.write(str.strip(i)) if float(i)<5.0: html.write('</font>') html.write('</td>\n')#media 2############################html.write('<td>')mediam=aluno.mediamat()if mediam<5.0: html.write('<font color="red">')mediam=str(mediam)html.write('<b>Média: </b>'+str.strip(mediam))if float(mediam)<5.0: html.write('</font>')html.write('</td>\n')html.write('</tr>')###################################html.write('<tr>\n')html.write('<td><b>Ciências</b></td>\n')for i in aluno.nota3: html.write('<td>') if i<5.0: html.write('<font color="red">') i=str(i) html.write(str.strip(i)) if float(i)<5.0: html.write('</font>') html.write('</td>\n')#media 3##########################html.write('<td>')mediac=aluno.mediacie()if mediac<5.0: html.write('<font color="red">')mediac=str(mediac)html.write('<b>Média: </b>'+str.strip(mediac))if float(mediac)<5.0: html.write('</font>')html.write('</td>\n')##################################html.write('</tr></tbody></table>\n')testamedia=0if aluno.mediapor() >= 5.0: testamedia+=1 passif aluno.mediamat() >= 5.0: testamedia+=1 passif aluno.mediacie() >= 5.0: testamedia+=1 passif testamedia == 3: html.write('<h2><font color="blue"><u>O aluno está aprovado!</u></font></h2>')elif testamedia == 2 or testamedia == 1: html.write('<h2><u>O aluno não foi aprovado em todas as materias e está de recuperação.</u></h2>')else: html.write('<h2><font color="red"><u>O aluno está reprovado.</u></font></h2>')html.write('\n</body>\n</html>')html.close()from os import systemsystem('firefox boletim.html')