Skip to content

Commit ac4f088

Browse files
committed
hw 2 + 3
1 parent a25f976 commit ac4f088

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
shuzu = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2+
shuzu.reverse()
3+
print (shuzu)
4+
zifuchuan = ''
5+
for i in range(len(shuzu)):
6+
zifuchuan = zifuchuan + str(shuzu[i])
7+
8+
print(zifuchuan)
9+
10+
zifuchuan_3t8= zifuchuan[3:9]
11+
print(zifuchuan_3t8)
12+
list_3t8 = []
13+
for i in range(len(zifuchuan_3t8)):
14+
list_3t8.append(zifuchuan_3t8[i])
15+
list_3t8.reverse()
16+
print (list_3t8)
17+
18+
string_3t8=''
19+
for i in range(len(list_3t8)):
20+
string_3t8 = string_3t8 + str(list_3t8[i])
21+
22+
int_3t8 = int(string_3t8)
23+
int_3t8_bin = bin(int_3t8)
24+
int_3t8_oct = oct(int_3t8)
25+
int_3t8_hex = hex(int_3t8)
26+
27+
print('bin: ' + str(int_3t8_bin))
28+
print('oct: ' + str(int_3t8_oct))
29+
print('hex: ' + str(int_3t8_hex))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1+
import collections
2+
import os
13

4+
text = '''
5+
The Zen of Python, by Tim Peters
6+
7+
8+
Beautiful is better than ugly.
9+
Explicit is better than implicit.
10+
Simple is better than complex.
11+
Complex is better than complicated.
12+
Flat is better than nested.
13+
Sparse is better than dense.
14+
Readability counts.
15+
Special cases aren't special enough to break the rules.
16+
Although practicality beats purity.
17+
Errors should never pass silently.
18+
Unless explicitly silenced.
19+
In the face of ambxiguity, refuse the temptation to guess.
20+
There should be one-- and preferably only one --obvious way to do it.
21+
Although that way may not be obvious at first unless you're Dutch.
22+
Now is better than never.
23+
Although never is often better than *right* now.
24+
If the implementation is hard to explain, it's a bad idea.
25+
If the implementation is easy to explain, it may be a good idea.
26+
Namespaces are one honking great idea -- let's do more of those!
27+
'''
28+
29+
text = text.replace('--', '')
30+
text = text.replace('!', '')
31+
text = text.replace('*', '')
32+
text = text.split()
33+
34+
35+
# value_list = list(range(1,len(text)+1))
36+
# print (value_list)
37+
# text_dict = dict(zip(text, value_list))
38+
39+
print (collections.Counter(text))

0 commit comments

Comments
 (0)