Python compatibility diagnostic program
from datetime import date
from time import strptime
new={'Gemini':'Aquarius','Taurus':'Virgo','Scorpio':'Pisces',\
'Leo':'Sagittarius','Capricorn':'Virgo','Cancer':'Aries'}
class seizaandeto:
def __init__(self):
self.seiza={1:'Capricorn',2:'Aquarius',3:'Pisces',4:'Aries',5:'Taurus',\
6:'Gemini',7:'Cancer',8:'Leo',9:'Virgo',10:'Libra',\
11:'Scorpio',12:'Sagittarius'}
self.printSeizaandeto()
def printSeizaandeto(self):
print('Enter your date of birth.')
year=input('Please enter the year of birth.')
month=input('Please enter the month of birth.')
day=input('Please enter the date of birth.')
s='%s-%s-%s'%(year,month,day)
dobj=date(*strptime(s,'%Y-%m-%d')[0:3])
self.year,self.month,self.day=dobj.year,dobj.month,dobj.day
x=self.seizaHantei()
print('What goes well with you' + new[x] + 'is.')
print("Birthday:%s" % dobj)
print('sign:%s' % (self.seizaHantei()))
def seizaHantei(self):
if self.day>22:
if self.month==12:
return self.seiza[1]
else:
return self.seiza[self.month+1]
else:
return self.seiza[self.month]
if __name__=='__main__':
v=seizaandeto()
How to make ① First, make a set with all the information of the constellations (2) Create a dictionary with keys as numbers and elements as constellation information, and skip to the method for entering the date of birth. ③ Identify the constellations ④ Appropriately determine compatibility and output
Recommended Posts