作业1
a = "python的创始人是Guido" print (a[(a.index('G')):(len(a))]) print (a[(len(a)):(a.index('G')-1):-1]) print(a[::3])
作业2
a = '你' b = '最帅' c = a + b d = a+b+b+b print(c) print(d)
作业3
from random import * for i in range(10): a = randint(0,1000) a = str (a) if a is a[::-1] : print (a)
作业4
for x in range(20): for y in range(33): for z in range(100): a = x+y+z b = 5*x+3*y+1/3*z if a == 100 and b == 100 : print(x,y,z)
作业5
a = input ( '请输入一段字符串' ) x = 0 y = 0 for i in a: if 'a' <= i <= 'z' or 'A' <= i <= 'Z': x += 1 if '0' <= i <= '9' : y += 1 print('字母的个数是{},数字的个数是{}。'.format(x,y))
作业6
y,m = eval ( input ( '请输入一个年月' ) ) if y < 1990 : print ( '你输入的年份有误!' ) d = 1 for i in range (y+1): if i > 1990 : if i % 4 == 0 and i % 100 != 0 or i % 400 == 0 : d += 366 else : d += 365 else : continue for n in range ( m ): if n in [ 1 , 3 , 5 , 7 , 8 , 10 , 12 ] : d += 31 elif n in [ 4 , 6 , 9 , 11 ] : d += 30 elif n == 2 : if y % 4 == 0 and y % 100 != 0 or y % 400 == 0 : d += 29 else : d += 28 f = d % 7
k = ['星期日','星期1','星期二','星期三','星期四','星期五','星期六']
print(k[f])