Questions about python

0

I'm new to python, and I'm trying to make a system, where you fill out a questionnaire, and consequently it already prints in html to just paste in the forum. What I put together was this:

from datetime import datetime

now=datetime.now()

ano=now.year

mes=now.month

dia=now.day

aprovados=input('Digite o(s) nick(s) do(s) aprovado(s): ')

naprovados=int(input('Digite o número de aprovados: '))

reprovados=input('Digite o nome do(s) aluno(s) reprovado(s): ')

nreprovados=int(input('Digite o número de alunos reprovados: '))

nalunos=naprovados + nreprovados

inicio=input('Digite o horário do início da aula: ')

termino=input('Digite o horário do término da aula:  ')

nsala=input('Digite a sala utilizada: ')

ag=input('Digite o nick do Guia (Se não houver digite "X"): ')

obs=input('Digite sua observação da aula')

print('[b]Nick do guia:[/b] [color=#0000ff] [b]WellersonOP [/b] [/color]')

print('[b]Patente e página: [/b] [color=#0000ff] [b]Aspirante [/b] [/color] [color=#ff0000][b][16/12-01][/b][/color]')

print('[b]Data da aula:[/b] [color=#0000ff] [b]{}/{}/{}[/b][/color]'.format(dia, mes, ano))

print(' ')

print('[color=#009900][b]Nick dos aprovados:[/b][/color] [b]{}
[/b]'.format(aprovados))

print('[color=#009900][b]Número de aprovados:[/b][/color] [b]{}[/b]'.format(naprovados))

print('[color=#009900][b]Número de civis:[/b][/color] [b]{}[/b]'.format(nalunos))

print(' ')

print('[color=#ff0000][b]Nick dos reprovados:[/b][/color] [b]{}[/b]'.format(reprovados))

print('[color=#ff0000][b]Número de reprovados:[/b][/color] [b]{}[/b]'.format(nreprovados))

print(' ')

print('[b]Horário de início:[/b] [b]{}[/b]'.format(inicio))

print('[b]Horário de término:[/b] [b]{}[/b]'.format(termino))

print('[b]Número da sala utilizada:[/b] [b]{}[/b]'.format(nsala))

print(' ')

print('[b]A.G:[/b] [b]{}[/b]'.format(ag))

print('[b]Observação:[/b] [b]{}[/b]'.format(obs))

print('[b]Sua assinatura:[/b]')

And it works perfectly though, I wanted to know how to make the days instead of appearing 1/6/2018, appearing 06/01/2018, but that did not affect when it was 10/11/2018 eg if I add If the 0 in front of the print of the date, when I put in that date, would appear 010/011/2018. Could someone give me the command for this along with the explanation?

I would also like to put it in AG, if no one types anything at all, a custom text would automatically appear, could you explain that too?

    
asked by anonymous 01.01.2018 / 17:13

2 answers

1

Make a concatenation of the day before printing, where it checks whether the printed value is less than or equal to day "9". Only equal or smaller values can receive a "zero" at the front. The values of 10 above (31) remain normal (I am not a Python user.I am an Object Pascal user.Check syntax details)

if dia<=9:dia = str("0" + dia)
    
01.01.2018 / 18:51
0

In the line that prints the date, try this:

print('[b]Data da aula:[/b] [color=#0000ff] [b]{}[/b][/color]'.format(now.strftime('%d/%m/%Y')))
    
01.01.2018 / 21:35