@Zemel-Yang
2016-09-26T01:38:06.000000Z
字数 1247
阅读 799
python homework
Author: Zongmeng Yang
Student number: 2014301020092
Design a programe to make my Eglish name moved on the screen.
Tips:
import osi = os.system('cls')
print(" ###")print(" # ")print(" # ")print(" # ")print(" ###")
Draw something you want (such as rocket, matchstick man) in a 80×80 bitmap and make it rotate.
Tips:
Make strings into lists.
a = "test"
l = list(a)
Make lists into strings.
a = "".join(l)
1.L1
I use a loop statement to make it work. It will add some space in each loop and then clean the screen.
[Code][1]
import osimport timei=os.system('cls')a0 = "##### ##### # # ##### # # # ###### # # ######"a1 = " # # ## ## # # # # # # # # # # "a2 = " # ##### # # # # ##### # # ###### # # # # ###"a3 = " # # # # # # # # # # # # # # # #"a4 = "##### ##### # # # ##### ##### # # # # # ######"b = 0while b < 11:print (' '*b+a0)print (' '*b+a1)print (' '*b+a2)print (' '*b+a3)print (' '*b+a4)time.sleep(1)i=os.system('cls')b += 1
Result
disadvantage: It can't move on the screen forever
2. L2
import timeimport osa=(" ############\n")b=(" ### ###\n")c=(" #### \n")d=("##################\n")e=(" ## \n")f=("##### ## ######\n")k=(" ######### ##\n")g=3*a+6*b+2*c+2*d+2*c+2*a+4*bh=3*e+3*f+4*k+3*f+3*ei=4*b+2*a+2*c+2*d+2*c+6*b+3*aj=3*e+3*f+4*k+3*f+3*eli=[g,h,i,j]i=0while i<20:print(li[i%4])time.sleep(1)i=i+1os.system('cls')
Result
Thanks To:
Shengyong Hu