Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions exercises/1901100191/1001S02E03_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
operator = input('请输入运算符(+、-、*、/):')
first_number = input('请输入第一个数字:')
second_number = input('请输入第二个数字:')

a = int(first_number)
b = int(second_number)

print('operator:', operator, type(operator))
print('first_number:', first_number, type(first_number))
print('second_number:', second_number, type(second_number))

if operator == '+':
print(a, '+', b, '=', a + b)
elif operator == '-':
print(a, '-', b, '=', a - b)
elif operator == '*':
print(a, '*', b, '=', a * b)
elif operator == '/':
print(a, '/', b, '=', a / b)
else:
print('无效运算符')
14 changes: 14 additions & 0 deletions exercises/1901100191/1001S05E05_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
a_list=[0,1,2,3,4,5,6,7,8,9]
a_list.sort(reverse=True)
print(a_list)
b=''.join(str(i) for i in a_list)
print(b)
c=b[2:8]
print(c)
d=c[::-1]
print(d)
int_value=int(d)
print(int_value)
print(bin(int_value))
print(oct(int_value))
print(hex(int_value))
38 changes: 38 additions & 0 deletions exercises/1901100191/1001S05E05_stats_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
s='''
The Zen of Python, by Tim Peters


Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated. 9 Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambxiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do
it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!'''
i=s.split()
b=[]
d=',.*!-'
for e in i:
for f in d:
e=e.replace(f,'')
if len(e):
b.append(e)
print(b)
g={}
b_set=set(b)
for h in b_set:
g[h]=b.count(h)
print(g)
print(sorted(g.items(),key=lambda x: x[1],reverse=True))
37 changes: 37 additions & 0 deletions exercises/1901100191/1001S05E05_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
s='''
The Zen of Python, by Tim Peters


Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated. 9 Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambxiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do
it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!'''
print('better' in s)
print(s.replace('better','worse'))
b=s.replace('better','worse')
print(b.split())
c=b.split()
d=[]
for e in c:
if e.find('ea')<0:
d.append(e)
print(d)
f=[g.swapcase()for g in d]
print(f)
f.sort()
print(f)