+ 2
Years to Century
I want to input a year like 2017 and then turn that into the century its in only using mathematical equations without the module. 2000 is the 20th and 1901 is the 20th.
2 odpowiedzi
+ 1
this isn't much of an answer but what I would do would be divide it by 100 and subtract 1 from that float.
+ 1
num=input("Enter The Year - ")
cen=num
cen=cen[:2]
cen=int(cen)+1
print("The year {}, is in the {}th century".format(num,cen))
I got the year input. Next I cut it into the first 2 digits. finally I turned those into numbers and added one, giving me the century. Printed it.
There is probably a better way, but it did the trick