大家好,小编为大家解答如何用python画一个心形图的问题。很多人还不知道python简单的画图代码爱心,现在让我们一起来看看吧!
火车头采集ai伪原创插件截图:
一行Python代码画心型
1、画I组成的心型代码:
print('\n'.join([''.join([('I'[(x-y) % len('I')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
2、画Love组成的心型代码:
print('\n'.join([''.join([('Love'[(x-y) % len('Love')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
3、画You组成的心型代码:
print('\n'.join([''.join([('You'[(x-y) % len('You')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
4、画Raven组成的心型代码:
print('\n'.join([''.join([('Raven'[(x-y) % len('Raven')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))