pegar seculo
unknown
python
a year ago
931 B
3
Indexable
Never
def intToRoman(num): # Armazenando valores romanos de dígitos de 0-9 # quando colocado em lugares diferentes m = ["", "M", "MM", "MMM"] c = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM "] x = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"] i = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"] # Convertendo para romano thousands = m[num // 1000] hundereds = c[(num % 1000) // 100] tens = x[(num % 100) // 10] ones = i[num % 10] ans = (thousands + hundereds + tens + ones) return ans def pegar_seculo(ano): seculo = int((ano-1)/100) + 1 seculo_romano = intToRoman(seculo) return seculo_romano while True: try: ano=int(input("Ano: ")) print("ano:",ano," Século:",pegar_seculo(ano)) break except: pass