homework

'''
2 定义一个字符串"python的创始人是Guido",试分别打印出"Guido","odiuG", "ph的人uo"
3 '''
4 '''
5 s = 'python的创始人是Guido'
6 print(s[11:16])
7
8 print(s[15:10:-1])
9 print(s[::3])
10 '''
11 '''
12 .有字符串"你"和"最帅",如何得到字符串"你最帅",又如何得到字符串"你最帅最帅最帅"
13
14 '''
15 '''
16 s1 = '你'
17 s2 = "最帅"
18 print(s1+s2)
19 print(s1+s2+s2+s2)
20 '''
21 '''
22 像121 11 111等对称的整型数称为回文整型数,随机产生1000以内的10个整型数,打印其中的回
文整型数
23 '''
24 '''

import random
26 for i in range (10):
27 n = random.randint(0,1000)
28 if n<100:
29
30 a = n%10
31 b = n//10
32 if a==b:
33 print(n)
34 else:
35 d = n%10
36
37 c = n//100
38 if d == c:
39 print(n)
40 '''
41 '''
42 公鸡5文钱1只,母鸡3文钱1只,小鸡3只1文钱,用100文钱买100只鸡,可以怎么买?
43 '''
44 #公鸡设为a 母鸡设为b 小鸡设为c

for a in range (21):
47 for b in range (34):
48 for c in range (300):
49 if 5*a + b*3 + 1/3*c == 100 and a + b +c == 100:
50 print('公鸡买{}只,母鸡买{}只,小鸡买{}只'.format(a,b,c))
51 '''
52
53
54
55 '''
56 使用input()读入一个字符串,统计字符串中字母的个数,和数字的个数
57
58 '''
59 '''
60 s = input ('请输入一个字符串:')
61 a = b = c =0
62 for i in s:
63 if "a"<=i<="z":
64 a += 1
65 elif 'A'<=i<='Z':
66 b += 1
67 else:
68 c += 1

print ('小写字母有%d个,大写字母有%d个,数字有%d个'%(a,b,c))

 

posted @ 2018-12-05 22:24  赵冀华  阅读(156)  评论(0编辑  收藏  举报