News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

Love code (python)

posted on 2023-05-03 20:05     read(203)     comment(0)     like(4)     collect(2)


In view of the fact that many friends are not very good at running, I will add my running method here~ (for python), those who don’t know how to run can just click "Run Steps"~

run steps


1. Python code (love.py)

  1. import time
  2. words = "love"
  3. print('\n')
  4. for item in words.split():
  5. letterlist = []
  6. for y in range(12, -12, -1):
  7. list_X = []
  8. letters = ''
  9. for x in range(-30, 30):
  10. expression = ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3
  11. if expression <= 0:
  12. letters += item[(x-y) % len(item)]
  13. else:
  14. letters += ' '
  15. list_X.append(letters)
  16. letterlist += list_X
  17. print('\n'.join(letterlist))
  18. time.sleep(0.5);
  19. print('\n to 茂茂酱!!\n\n')

Running diagram: 

Two, python code (love.py)

  1. import turtle as t
  2. # 布置画布和设置画笔配置
  3. t.setup(width=800, height=500) #窗口(画布)大小
  4. t.color('pink', 'pink') #画笔填充颜色
  5. t.pensize(3) #画笔粗细
  6. t.speed(1.5) #描绘速度
  7. # 开始画
  8. t.begin_fill() #开始填充颜色
  9. t.up() # 提笔
  10. t.goto(0, -100) # 移动画笔到指定坐标
  11. t.down() # 下笔
  12. t.left(45) #笔向向左45
  13. t.forward(200) #画出长度为200的直线
  14. t.circle(100,180) #绘制直径为100,角度为180度的半圆
  15. t.right(90) #笔向向右90
  16. t.circle(100,180) #绘制直径为100,角度为180度的半圆
  17. t.forward(200) #画出长度为200的直线
  18. t.end_fill() #结束填充颜色
  19. # 写文字
  20. t.up() #提笔
  21. t.goto(-120, -120) #移动画笔到指定坐标
  22. t.down() #下笔
  23. t.write('祝茂茂',align='center',font=('宋体','20')) #文字可以随意调整,slign是对齐方式,font是字体和字号
  24. t.up() # 提笔
  25. t.goto(120, -120) #移动画笔到指定坐标
  26. t.down() #下笔
  27. t.write('天天开心',align='center',font=('宋体','20'))

 Running diagram: 

 3. C language code (love.c)

  1. #include<stdio.h>
  2. #include<Windows.h>
  3. int main()
  4. {
  5. float x,y,a;
  6. for(y=1.5; y>-1.5; y-=0.1)
  7. {
  8. for(x=-1.5; x<1.5; x+=0.05)
  9. {
  10. a=x*x+y*y-1;
  11. putchar(a*a*a-x*x*y*y*y<=0.0?'*':' ');
  12. }
  13. system("color 0c");
  14. putchar('\n');
  15. }
  16. printf("\t\t\t\t\t茂茂天天开心~\n\n");
  17. return 0;
  18. }

Running diagram: 


Operation steps:

Since many friends are not very good at running, I will add my running method here~ (for python)

Step 1: Create a folder anywhere (preferably the desktop, it will be convenient to delete it later~)

 Step 2: Open the Test folder, enter, create a file with the suffix .py, and name it randomly

//No, no, if you want to learn programming, if the computer can't directly change the suffix, then it's not competent enough~ (fork away, go to Baidu)

 Step 3: Enter cmd on the navigation side and press enter (shortcut terminal mode)

 

 Step 4: Enter python+space+the full name of the python file you created. The example is as follows:

python love.py

 press enter to run

 Pure nanny level~~~~~



Category of website: technical article > Blog

Author:Fiee

link:http://www.pythonblackhole.com/blog/article/272/9d2e58901b7c86e3e890/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

4 0
collect article
collected

Comment content: (supports up to 255 characters)