blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e183e30a48514766f0c80fe4011581c292712553 | shen-huang/selfteaching-python-camp | /19100402/weizhihao1994/weizhihao.py | 342 | 3.625 | 4 | for i in range(1,10):
for n in range(1,10):
if i>=n:
print(i,'*',n,'=',i*n,end='\t')
elif i<n:
print(' ')
break
x=0
while x<9:
x += 1
if x%2 != 0:
y=1
while x>=y:
print(x,'*',y,'=',x*y,end='\t')
y += 1
else:... |
39a1cf86916274791f4b0678da8b3c6bd327712a | shen-huang/selfteaching-python-camp | /exercises/1901060030/1001S02E03_calculator.py | 1,523 | 4.375 | 4 | # Below is a simple calculator which can perform adding, substracting, multipling, dividing, getting quotient, or getting remainder from the two numbers entered by user
# Firstly create functions for operations
def add (x,y):
return x+y
def substract (x,y):
return x-y
def multiple (x,y):
return x*y
def divi... |
b1cbcc8d811fe83d03bc1ec2b5fa233b4dd1543d | shen-huang/selfteaching-python-camp | /19100103/lucasLu0724/d3_exercise_calculate.py | 555 | 4.125 | 4 | print("helloworld")
def cal():
print("welcome")
num1=float(input("please input the num1"))
num2=float(input("please input the num2"))
option =input("please input the option :+ - * /")
if option=="+":
print("{0}+{1}=".format(num1,num2),num1+num2)
elif option=="-":
print("{0}-{1}... |
7c2b4d2d48ed19313ed8ac1a5d2d2d130f2cf4ab | shen-huang/selfteaching-python-camp | /19100303/liyan2019/d5_exercise_stats_text.py | 1,973 | 3.796875 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
97e44e475d074b607a65aa6482a68e3c1f4f2e96 | shen-huang/selfteaching-python-camp | /exercises/1901100236/1001S02E03_calculator.py | 740 | 3.984375 | 4 |
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), type(a))
print('second_nubmer', second_number, type(second_nu... |
00f3f323ef1710d64e37acf9b82cd37e7796cd8a | shen-huang/selfteaching-python-camp | /exercises/1901010064/1001S02E04_control_flow.py | 1,016 | 3.6875 | 4 | for i in range(1,10):
if i < 2:
print(f"{i}*1={i}")
if 1 < i < 3:
print(f"{i}*1={i}" f"\t{i}*2={i*2}")
if 2 < i < 4:
print(f"{i}*1={i}" f"\t{i}*2={i*2}"f"\t{i}*3={i*3}")
if 3 < i < 5:
print(f"{i}*1={i}" f"\t{i}*2={i*2}"f"\t{i}*3={i*3}"f"\t{i}*4={i*4}")
if 4 < i < 6:
... |
b3237c17f5205a09568692a53037f1c1f5e15f1d | shen-huang/selfteaching-python-camp | /exercises/1901050136/d08/mymodule/stats_word.py | 2,846 | 3.859375 | 4 | # this script is to learn try except finally raise
# 1 for english word
def stats_text_en(text):
# judge if the type of input is correct.
if type(text)==str:
pass
else:
raise ValueError('The input text is not the type of String')
text = text.strip().split()
words = [] # for store t... |
8276219cec6fb6475a24bb13f61417a48f1269d7 | shen-huang/selfteaching-python-camp | /exercises/1901100151/1001S02E05_string.py | 1,794 | 3.515625 | 4 | # from IPython.core.interactiveshell import InteractiveShell
# InteractiveShell.ast_node_interactivity = "all"
text = '''
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.
Flat is better than nested.
Sp... |
ad0af151c822548acb62f91be3394fd17e145b25 | shen-huang/selfteaching-python-camp | /exercises/1901040001/1001S02E05_array.py | 437 | 3.875 | 4 | tuple1 = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
#翻转数组
list1 = list(tuple1)
list1.reverse()
tuple2 = tuple(list1)
#拼接字符串
string1 = ""
string1 = "".join([str(i) for i in list1])
#特定字符串切片
string2 = string1[2:8]
#翻转切片后的字符串
string3 = string2[::-1]
#字符串转换为整形
value1 = int(string3)
value2 = bin(value1)
value3 = oct(value1)
value4 = he... |
cb88ab350107653803c275a86578b7f34d9f0693 | shen-huang/selfteaching-python-camp | /19100205/11661246/d6_exercise_stats_word.py | 1,971 | 4 | 4 | #统计参数中每个英文单词出现的次数,按词频降序排列数组
def stats_text_en(text): # 统计英文词频
text = text.replace('.', '')
text = text.replace('!', '')
text = text.replace('--', '')
text = text.replace('*', '')
text = text.replace(',', '') # 去除标点符号
list_text = text.split() # 将字符串转换为列表
import collections
m=collectio... |
ddd01198ad84da784dec1d5a4d5f64c331665946 | shen-huang/selfteaching-python-camp | /exercises/1901050193/1001S02E05_string.py | 1,433 | 4 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
c0ade18c78bb6e154d267b3f1cb5eb6384e0e825 | shen-huang/selfteaching-python-camp | /exercises/1901040001/d09/mymodule/stats_word.py | 1,635 | 3.71875 | 4 | import collections
import re
#将中文进行词频统计。
def stats_text_cn(text):
if type(text) == str:
list1 = re.findall(r'[\u4e00-\u9fa5]', text)
count = int(input("Please input the number of elements to be output in cn_text:"))
word_frequencycount_cn = collections.Counter(list1).most_common(count)
... |
a2abdffd58028fb33138312dff0540ba7603dc13 | shen-huang/selfteaching-python-camp | /exercises/1901040051/d09/mymodule/test3.py | 864 | 4 | 4 | # from collections import Counter
# #首先导入Counter类
# lst=['this','is','a','test','just','a','test','you','shoud','believe','in','this','me','just','a','test','a','test','a','test']
# #构建一个列表
# word_count=Counter(lst)
# #首先对列表的元素进行一次统计
# top_three=word_count.most_common(3)
# #调用most_common方法找出最多的元素
# print(top_three)
# #... |
143f0fddc0436bbddd35055000676752f97ce746 | shen-huang/selfteaching-python-camp | /exercises/1901010133/1001S02E05_array.py | 326 | 3.609375 | 4 |
a1=[0,1,2,3,4,5,6,7,8,9]
a2=a1.reverse()
print(a1)
str1="".join(str(i)for i in a1)
print(str1)
str2=str1[2:8]
print(str2)
str3=str2[::-1]
print(str3)
num=int(str3)
print(num)
print("十进制数为:",num)
print("转二进制为:",bin(num))
print("转八进制为:",oct(num))
print("转十六进制为:",hex(num))
|
32ad6b5e041876a7fb7a2643d5ec4dbd85cc3ff6 | shen-huang/selfteaching-python-camp | /exercises/1901010055/1001S02E05_array.py | 673 | 3.84375 | 4 | array=[0,1,2,3,4,5,6,7,8,9]
array.reverse()
print(array)
array1=[]
for i in array:
array1.append(str(i))#字符串
print(array1)
array2 = ''.join(array1)#拼接
print(array2)
array3 = array2[2:8]#取值
print(array3)
array4 = []
for i in array3:
array4.append(str(i))#字符串
array4.reverse()#翻转
print(array4)
array5 = ''.join(arr... |
5634d1f8339bc78cc8816ae2ff2959af494a3c74 | shen-huang/selfteaching-python-camp | /19100203/sztanbu/d4_exercise_control_flow.py | 377 | 4.28125 | 4 | #乘法表 用for in and while
def multiply_for(n):
for d in range(1,n+1):
for e in range(1,d+1):
print(d,'*',e,'=',d*e,end='\t')
print()
def multiply_while(n):
a=1
while a<=n:
b=1
while b<=a:
print(a,'*',b,'=',a*b,end='\t')
b=b+1
print()... |
954d7ca94148faf7836462fa14099ae0d625ee3d | shen-huang/selfteaching-python-camp | /exercises/1901040049/1001S02E04_control_flow.py | 281 | 3.875 | 4 | for i in range (1,10):
for j in range (1,i+1):
print('%d*%d=%2d\t'%(i,j,i*j),end='')
print()
for i in range(1,10):
while i%2==0:
break
else:
for j in range(1,i+1):
print('%d*%d=%2d\t'%(i,j,i*j),end='')
print()
print()
|
9f0f9b4506354064475dcdc5109cdfb5f313ee0b | shen-huang/selfteaching-python-camp | /19100202/blocklife/d4_exercise_control_flow.py | 359 | 3.578125 | 4 | for i in range(1,10):
for j in range(1, i+1):
sum = i * j
print(str(i) + "*" + str(j) + "=" + str(sum), end='\t')
print()
print('-----while循环-----')
x = 1
while x <= 9:
y = 1
while y <= x:
mul = x * y
print(str(x) + "*" + str(y) + "=" + str(mul), end='\t')
y = ... |
d34f541e147718afa4cce1df2598ea207d3fbc04 | shen-huang/selfteaching-python-camp | /exercises/1901100089/Test.py | 108 | 3.6875 | 4 | s = "Python"
for i in range(len(s)):
print(s[i])
# 可以实现替换
print(s.replace('P','O'))
print(s) |
f454f299fa3b689c2d63b65de2f51688003c318c | shen-huang/selfteaching-python-camp | /exercises/1901010134/1001S02E03_calculator.py | 791 | 4.21875 | 4 | #并不会写,只能抄一遍
#calculator
#定义函数
def add(x,y):
return x + y
def substract(x,y):
return x - y
def multiply(x,y):
return x * y
def divide(x,y):
return x / y
#用户输入
print("选择运算,")
print("1、相加")
print("2、相减")
print("3、相乘")
print("4、相除")
num1 = int(input("请输入第一个数字:"))
choice = input("请输入你的选择(1/2/3/4... |
3db6970053bc413e9e81681b6006f39c2c2869b5 | shen-huang/selfteaching-python-camp | /exercises/1901050060/1001S02E03_calculator.py | 608 | 3.53125 | 4 | def jia(a,b):
return(a+b)
def jian(a,b):
return(a-b)
def chen(a,b):
return(a*b)
def chu(a,b):
return(a/b)
num1 =int(input('请输入第一个数字:'))
num2 =int(input('请输入第二个数字:'))
fuhao=input('请选择运算符:1、相加 2、相减 3 、相乘 4、相除 : ')
if fuhao =="1":
print(num1,'+',num2,'=',jia(num1,num2))
elif fuhao =="2":
... |
c013f43f22eeb0138c39f2a8ba153fea0b8b0bb7 | shen-huang/selfteaching-python-camp | /exercises/1901100025/1001S02E05_stats_test.py | 1,362 | 4.03125 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although ... |
ac68fa066fc3d29c98300553b2ceca52b2bfad2c | shen-huang/selfteaching-python-camp | /exercises/1901010076/d3_exerclse_calculator.py | 922 | 4.25 | 4 | # 这是邓超抄写的第一个简单程序
# 可以运算加减乘除的简易计算器
# 定义函数
def add(x, y):
"""相加"""
return x + y
def subtract(x, y):
"""相减"""
return x - y
def multiply(x, y):
"""相乘"""
return x * y
def divide(x, y):
"""相除"""
return x / y
# 用户输入
print("选择运算,")
print("1、相加")
print("2、相减")
print("3、相乘")
print("4、相除")... |
f9ec2f9b7810a962f1e8226af23d7a793ed713cc | shen-huang/selfteaching-python-camp | /19100203/Young4/d6_exercise_stats_word.py | 3,137 | 3.625 | 4 | '''
1.创建一个名为d6_exercise_stats_word.py的文件
2.定义一个名为stats_text_en的函数,函数接受一个字符串text作为参数
3.实现该函数的功能(同day5任务2):统计参数中每个英文单词出现的次数
最后返回一个按词频降序排列的数组
4.为Stats_text_en添加注释说明
'''
import re
def stats_text_en(text): #定义函数
text_1 = re.sub('\W',' ',text) #不是字符的,都转换为空格。主要去除标点符号
text_1 = text_1.lower() #转换为小写
textlist_1... |
f2228f4f86dc46d53c6b8796ebe210bc96bc30f8 | shen-huang/selfteaching-python-camp | /19100302/feioman/d4_exercise_control_flow.py | 927 | 3.578125 | 4 | #任务1for语句
print("---"* 20)
print('<feioman乘法表1>')
for i in range(1,10):
for x in range(1,i+1):
print( '%d X %d = %2d' % (i ,x ,i*x) ,end = ' ' )
print(' ')
#
print("---"* 20)
#
#任务2.1 while语句
print('《feioman乘法表2》')
i = 1
while i < 10:
j = 1
while j < i+1:
print('%d X %d = %2d' %(i ,j... |
5744ca40482a6437bff526891d0d4f3916e26132 | shen-huang/selfteaching-python-camp | /exercises/1901100030/1001S02E05_stats_text.py | 1,713 | 4.09375 | 4 | # day5 字符串练习
# 2019年7月9日
# 陈浩 学号 1901100030
text = '''
The Zen of Python, by Tim Peters
#<<<<<<< master
#=======
#>>>>>>> master
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than den... |
fe3ab67e5c9f5ac3b608d7e195fc9a5f20becd22 | shen-huang/selfteaching-python-camp | /exercises/1901090061/1001S02E06_stats_word.py | 5,408 | 3.765625 | 4 | #创建一个函数,接收字符串text作为参数
def stats_word_en(text):
"""
stats_word_en 可接收一个英文字符串text作为参数,统计参数中每个英文单词出现的次数,最后返回一个按词频降序排列的数组
"""
#创建一个空列表
words = []
#想要删除的标点符号
symbols = '.,!-*'
#将字符串text分割后赋值给elements,其中包含标点符号,英文单词,和空格,elements数据格式为列表
elements = text.split()
#遍历elements中的每一个element
... |
8be40b734e7818850f7b882f7c3b247cbba21625 | shen-huang/selfteaching-python-camp | /exercises/1901090011/1001S02E04_control_flow.py | 432 | 3.96875 | 4 | # Define function
def Multiplication(x, y):
"""Multiplication"""
return x * y
# Task#1
for i in range(1,10,1):
for j in range(1,i+1,1):
print(i,"*",j,"=", Multiplication(i, j)," ",end="")
print("")
print("")
# Task#2
i=1
while i<10:
if i%2==1:
j=1
while j<=i... |
85fcb9f2f4862cd3211517b450121950857faab2 | shen-huang/selfteaching-python-camp | /exercises/1901010116/1001S02E03_calculator.py | 728 | 4.21875 | 4 | #定义函数
def add(x,y):
return x + y
def subtract(x,y):
return x - y
def multiply(x,y):
return x * y
def divide(x,y):
return x / y
#用户输入
print("请选择运算:")
print("1、相加")
print("2、相减")
print("3、相乘")
print("4、相除")
choice = input("请输入您的选择(1/2/3/4):")
num1 = float(input("请输入第一个数字:"))
num2 = float(input("请输入第二个数... |
11f19f34d1645006a1bb489d7ce522c59802e31c | shen-huang/selfteaching-python-camp | /exercises/1901050044/1001S02E04_control_flow.py | 186 | 4 | 4 | def multiply(x,y):
return x * y
a = 1
while a < 10:
for b in range (1, a+1):
print(a,"*",b,'=',multiply(a,b),end='\t')
a = a + 1
print()
|
751f394f032ed75ea395a204466e6233e3da8434 | shen-huang/selfteaching-python-camp | /exercises/1901060030/d07/mymodule/stats_word.py | 918 | 3.5625 | 4 | def stats_text_en(text):
from collections import Counter
text = ascii(text)
new_list = text.split(' ')
new_list1 = []
for i in new_list:
new_list1.append(i.lower())
print(Counter(new_list1))
def stats_text_cn(text):
from collections import Counter
new_list3 = []
for i in text... |
5067e991101d358c8f971cb83473b17e5b25dd78 | shen-huang/selfteaching-python-camp | /exercises/1901100088/1001S02E04_control_flow.py | 343 | 3.9375 | 4 | for x in range(1,10):
for y in range (1,x+1):
z=x*y
print("%d*%d=%d"%(x,y,z),end=" ")
print()
print("\n")
#for x in range(1,10,2):
for x in range(1,10):
while x % 2 == 0:
break
else:
for y in range (1,x+1):
z=x*y
print("%d*%d=%d"%(x,y,z),end=... |
35182f6a38de7ce3054e93360f33a330609c5bca | shen-huang/selfteaching-python-camp | /exercises/1901110002/1001S02E03_calculator.py | 635 | 4.25 | 4 | #计算器支持加减乘除
operator= input("pls input character (+,-,*,/):")#()内内容为提示内容
first_number=input("first_number:")
second_number=input("second_number:")
a=float(firs_tnumber)
b=float(second_number)
print("operator:",operator,type(operator))
print("first_number:",first_number,type(first_number),type(a))
print("seco... |
24bcf7ffcd41b44c2fce558da142a5d51dd3abfa | shen-huang/selfteaching-python-camp | /exercises/1901060008/1001S02E05_stats_text.py | 1,383 | 3.734375 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
91d4876ab0ec74c7bad74ed3e5cd2a5c94d29bd6 | shen-huang/selfteaching-python-camp | /exercises/1901100012/1001S02E06_stats_word.py | 2,666 | 3.609375 | 4 | en_text='''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although ... |
ff1592d1eb75eb9683507adf58965d69888e7939 | shen-huang/selfteaching-python-camp | /19100202/Gdong24/d4_exercise_control_flow.py | 132 | 3.640625 | 4 | for i in range(1,10,1):
for j in range(1,10,1):
print("{0} x {1} = {2}".format(i,j,i*j),end = "\t")
print('\t')
|
ac7dce30f7e92b7b346913f28c00d1a5da86d74c | shen-huang/selfteaching-python-camp | /19100402/zhangshuzhong/1001S01E05_stats_text.py | 2,491 | 3.734375 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
e3c4feaeefc85a0356973782ea774a19916b4a45 | shen-huang/selfteaching-python-camp | /exercises/1901050193/001S02E04_control_flow.py | 285 | 3.875 | 4 | for i in range(10):
for j in range(1,i+1):
print(i,'*',j,'=',i*j,end='\t')
if i==j:
print()
i=1
while i in range (10):
if i % 2==0:
print()
else:
for j in range(1,i+1):
print(i,'*',j,'=',i*j,end='\t')
i+=1 |
059fe4f75eebfa735b88254c0b8184b57fc0737c | shen-huang/selfteaching-python-camp | /exercises/1901050095/d07/mymodule/stats_word.py | 4,095 | 3.734375 | 4 | #text = ''' 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. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although ... |
875c027e5bc7ad576fe39ae533a3a14859121169 | shen-huang/selfteaching-python-camp | /exercises/1901040031/1001S02E05_string.py | 1,385 | 3.71875 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases arent't special enough to break the rules.
Although p... |
7758e170a4ca54bae93e3dcdadd9952ba9d76782 | shen-huang/selfteaching-python-camp | /exercises/1901050028/1001S02E05_string.py | 1,457 | 3.796875 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
817fb26089c0d09be5a1f408c7f24886abbbdc20 | shen-huang/selfteaching-python-camp | /exercises/1901010120/1001S02E04_control_flow_new.py | 788 | 4 | 4 | print("welcome to 9*9 tables:")
# loop in 9*9 tables
for a in range(1,10): # 指定a的范围是1到9
for b in range(1,a+1):#指定b的范围是1到a+1, 起点是1,止点是:如果a是1,b就是a+1=2
print('{}*{}={}\t'.format(b,a,a*b), end='')# 输出形态是用format定义为a*b,用end来自动回车
print()
#########过滤偶数########
print("welcome to 9*9 tables without even number:"... |
79876817e2a32e45dbf9434f36857f19a6b0debf | shen-huang/selfteaching-python-camp | /exercises/1901100025/1001S02E05_array.py | 759 | 4.0625 | 4 | numbers = [0, 1, 3, 4, 5, 6, 7, 8, 9]
numbers.reverse()
print('This is the homework 3.2 reverse:', numbers)
# 翻转后的数组拼接成字符串
numbers_string = []
for number in numbers:
numbers_string.append(str(number))
s = ''
str_join = s.join(numbers_string)
print('This is homework 3.3 join string:\n', str_join)
# ⽤字符串切⽚的⽅式取出第三到第⼋个... |
0ea5dc5b8a71cc557f4c289e7a5ea952b8bd9fe6 | shen-huang/selfteaching-python-camp | /19100303/YORKCHENYAN/d3_exercise_calculator.py | 719 | 4 | 4 | # 第三天作业:简单计算器
caculation = input("这是一个简单的计算程序,请输入要进行的运算,加法,减法,乘法,除法: ")
number_1 = int(input("请输入第一个数字: "))
number_2 = int(input("请输入第二个数字: "))
if caculation == "加法":
print("两者相加的结果是:" )
print(number_1 + number_2)
elif caculation == "减法":
print("两者相减的结果是:" )
print(number_1 - number_2)
elif ca... |
7fc785e118ccaad4d66ce80de6edf8211f760db1 | shen-huang/selfteaching-python-camp | /19100401/Cyborg9999/1001S01E06_stats_word.py | 3,154 | 4.15625 | 4 | text = '''
Alice was beginning to get very bored.She and her sister were sitting under the trees.
Her sisterwas reading,but Alice had nothing to do.Once or twice she looked into her sister's book,
but ithad no pictures or conversations in it.
爱丽丝开始觉得有点无聊了。她和姐姐正坐在树下。姐姐在看书,而爱丽丝无事可做。
她不时看看姐姐的书,里面既没有图画,也没有对话。
And what is... |
0192a6eed10f87b631a294d0da9f46592c4afbc0 | shen-huang/selfteaching-python-camp | /exercises/1901100043/1001S02E03_calculator.py | 1,556 | 4.3125 | 4 | x = input('please input a number x:')
y = input('please input a number y:')
op = input('please input an operator + - * /:')
if op == '+' :
print(float(x)+float(y))
elif op == '-':
print(float(x)-float(y))
elif op == '*':
print(float(x)*float(y))
else: #op == '\/'
print(float(x)/float(y))
'''
几点练习感受和想... |
6e8695b0225ffc6f839cd160c8884b9e6cbd0f06 | shen-huang/selfteaching-python-camp | /exercises/1901090002/1001S02E05_array.py | 292 | 3.703125 | 4 | list = [0,1,2,3,4,5,6,7,8,9]
list.reverse()
str_mine = ''
for num in list:
str_mine += str(num)
new_str = str_mine[2:8]
str_reverse = new_str[::-1]
str_to_int = int(str_reverse)
two = bin(str_to_int)
eight = oct(str_to_int)
sixteen = hex(str_to_int)
print(two)
print(eight)
print(sixteen) |
3188456219382fd18af940f9677d925ac7011ea2 | shen-huang/selfteaching-python-camp | /19100202/Gdong24/d4_exercise_control_flow_3.py | 139 | 3.53125 | 4 | i=1 #row
while i<=9:
j = 1 #column
while j<=i:
print("%dx%d=%d"%(i,j,i*j),end=' ')
j=j+1
print(' ')
i+=2 |
0f4303a475a9b393a81d8884deb4f6a6e30db7bd | shen-huang/selfteaching-python-camp | /exercises/1901050043/1001S02E04_control_flow.py | 349 | 3.5 | 4 | print('**打印九九乘法表**')
for i in range(1,10):
for j in range (1,i+1):
print(f'{i}*{j}=',j*i,end='\t')
print()
print('+++打印九九乘法表,偶数行+++')
n=1
while n<10:
if n%2==1:
m=1
while m<n+1:
print(f'{n}*{m}=',n*m,end='\t')
m+=1
print()
n+=1
print()
|
1199c8832c38ce61b7e1d2ae71c51a61944963c6 | shen-huang/selfteaching-python-camp | /exercises/1901050040/1001S02E04_control_flow.py | 557 | 3.640625 | 4 | for hang in range(1,10):#表示从1开始一共有9行
for lie in range(1,hang+1):#表示列,每行的列数等于行数
ji=hang*lie#九九乘法表就是两个数相乘得出一个积
print("{0}*{1}={2}{3}".format(hang,lie,ji,"\t"),end="")#"\t"是转义字符,意为向右移动一位使表格排列整齐
print("")
print("只打印奇数行")
for hang in range(1,10):
while hang%2==1:
for lie in range (1,ha... |
d7dc6713388d26977185c7634569caa14a7d12d2 | shen-huang/selfteaching-python-camp | /19100305/luokaiwen1022/d4_exercise_control_flow1.py | 911 | 4.09375 | 4 | print("Welcome!") #打印:欢迎界面
print('- for -') #使用for...in循环
for i in range(1, 10): #给i赋值,i是1、2、3、4、5、6、7、8、9。(取值时顾头不顾尾)
for j in range(1, i+1): #给j赋值,i是1时,j就是range(1,2),j取值就是1;i是2时,j就是range(1,3),j取值就是1、2……以此类推
print("%d * %d = %d" % (i, j, i*j), end='\t') #打印:按照设定打印九九乘法表
... |
f1c45ae4371610ff3f44146822a9b40dc114e099 | shen-huang/selfteaching-python-camp | /exercises/1901030029/d07/mymodule/stats_word.py | 2,448 | 3.765625 | 4 | text='''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although prac... |
08ba1136f4af6f56884e7caadb52277d40233cc2 | shen-huang/selfteaching-python-camp | /exercises/1901100004/1001S02E05_array.py | 331 | 3.71875 | 4 | list = [0,1,2,3,4,5,6,7,8,9]
list.reverse()
print(list)
list2 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
list3 = [str(i)for i in list2]
str1 = ''.join(list3)
print(str1)
str2 = str1[2:9]
print(str2)
str3 = str2[::-1]
print(str3)
num1 = int(str3)
two = bin(num1)
eight = oct(num1)
sixteen = hex(num1)
print(two)
print(eight)
print... |
0a3f183bea40430de73284aab80cf732a2f71f40 | shen-huang/selfteaching-python-camp | /19100305/luokaiwen1022/d5_exercise_array.py | 1,034 | 4.21875 | 4 | #这是一个关于数组操作和进制转换的程序
#3.1翻转数组
arr1 = [1,2,3,4,5,6,7,8,9]
arr1.reverse() #翻转数组arr1
print(arr1)
#3.2将数组拼接成字符串
str1 = ''.join(map(str,arr1)) #Python join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。
#map() 会根据提供的函数对指定序列做映射。第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。
print(str1)
#3.3用字符串切片方式取出str1中第三到第八个字... |
e70adc4bf9314c1d3a1c7a2bf8d39322e1182204 | shen-huang/selfteaching-python-camp | /exercises/1901010140/1001S02E05_string.py | 2,442 | 3.578125 | 4 | #将字符串串样本 text ⾥里里的 better 全部替换成 worse
text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special ... |
a48f95e50186a623be328fa5bce7e19226612117 | shen-huang/selfteaching-python-camp | /19100204/xin-yanyu/d2_exercise_hello_python.py | 1,807 | 4.15625 | 4 | # 第一个Python程序
# 自学的第一步
# 第二天的作业
# 向老师、同学问好
# 用列表、遍历打印Python之禅
# 2019.3.22
# --------------
# word变量,问候语
word = "hello world "
# 首字母大写
print(word.title())
# ————以下为Python之禅
print("\n====================")
# import_this为列表
import_this = [">>> import this"]
# 在列表中添加新内容
import_this.append("The Zen of Python, by Tim Pe... |
24d6d03627f517acb82fa6e768436cffc604ce99 | shen-huang/selfteaching-python-camp | /exercises/1901100244/1001S02E04_control_flow.py | 4,165 | 3.65625 | 4 | # -*- coding: UTF-8 -*-
# Filename : 1001S02E04_control_flow.py
# author by : @shen-huang
# 打印两种九九乘法表
# 任务原始要求
# 使用 for...in 循环打印九九乘法表
for i in range(1, 10):
for j in range(1, i+1):
print("{0}*{1}={2}".format(i, j, i*j), end=' ')
print()
print()
# 使用 while 循环打印九九乘法表并用条件判断把偶数行去掉
i = 1
while i < ... |
842a84901c494d9f23807b99234e78b79c2c4bfc | shen-huang/selfteaching-python-camp | /exercises/1901040028/1001S02E04_control_flow.py | 499 | 3.703125 | 4 | #for i in range(1,10):#定义行,确定第几行
# for j in range(1,i+1):#定义列,使列<=行,确定该行共有多少列,先完成内层循环后,再做外层循环。i=1时,j=1时,打印出1×1,i=2时,j=1打印出结果,再循环为j=2,依次类推
# print(j,"×",i,"=",j*i,"\t",end='')
# print()
i=0
while i<9:
i=i+1
if i%2==0:
continue
j=1
while j<=i:
print(i,"×",j,"=",i*j,"\t",... |
2705bbc1c90489bafcf8fb3135b71a172f25e143 | shen-huang/selfteaching-python-camp | /19100104/Jacquesxu666/d3_exercise_caculator.py | 916 | 3.734375 | 4 | def jia(x,y): #function for plus
return x + y
def jian(x,y): # function for minus
return x - y
def chen(x,y): #function for multiplus
return x*y
def chu(x,y): #function for divide
return x/y
print("Please choose your operation: 1 for plus,2 for minus, 3 for multiplus, 4 for divide")
selection = in... |
39758a242da63f6fae080a67e91105a571eb9051 | shen-huang/selfteaching-python-camp | /exercises/1901010100/1001S02E04_control_flow.py | 272 | 3.984375 | 4 | for i in range(1, 10):
for j in range(1, i+1):
print(j,"*",i,"=",i*j,end="\t")
if i == j:
print()
for i1 in range(1, 10, 2):
for j1 in range(1, i1+1):
print(j1,"*",i1,"=",i1*j1,end="\t")
if i1 == j1:
print()
|
06a047c38a8f0164c32cd064602c1c62c72e3ffa | shen-huang/selfteaching-python-camp | /19100105/quan0523/d3_exercise_calculator.py | 907 | 4.09375 | 4 | def add(x, y):
print("x is {} and y is {}".format(x, y))
return x + y
def subtract(x, y):
print("x is {} and y is {}".format(x, y))
return x - y
def multiply(x, y):
print("x is {} and y is {}".format(x, y))
return x * y
def divide(x, y):
print("x is {} and y is {}".format(x, y))
r... |
40e07725b0441dc0093903a959a635691e89f5ce | shen-huang/selfteaching-python-camp | /exercises/1901050029/1001S02E03_calculator.py | 1,019 | 4.0625 | 4 | # Filename : 1001S02E03_calculator
# author by : Ž
# 庯
def add(x, y):
""""""
return x + y
def subtract(x, y):
""""""
return x - y
def multiply(x, y):
""""""
return x * y
def divide(x, y):
""""""
return x / y
########################################################
status = 1
# û
pr... |
62b39d7d9cea22781bc2e2252ee5d1f0bb02bf3e | shen-huang/selfteaching-python-camp | /exercises/1901050024/1001S02E06_stats_word.py | 2,235 | 3.65625 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
557f918bb51becd22c34d4eec3c096b576bda35b | shen-huang/selfteaching-python-camp | /19100304/baichampion/d5_exercise_string.py | 2,805 | 3.5625 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although p... |
28591228acef49ea6e782c2f2972a0e7684565dd | shen-huang/selfteaching-python-camp | /exercises/1901050092/1001S02E05_stats_text.py | 1,274 | 3.65625 | 4 | sample_text='''
The Zen of Python,by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
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... |
1249d7789740c3658880c81d83c8da93facb498a | shen-huang/selfteaching-python-camp | /19100402/zhangshuzhong/1001S01E05_string.py | 2,087 | 3.734375 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
a2c6201a711e0089502670372fb1b835dd0ff691 | shen-huang/selfteaching-python-camp | /exercises/1901010092/1001s02e06_stats_word.py | 2,676 | 3.734375 | 4 | text1 = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Alth... |
80a712c7d682b8e1595e7f92f5343e57c9442776 | shen-huang/selfteaching-python-camp | /exercises/1901050029/1001S02E05_string.py | 1,572 | 3.625 | 4 | # Filename : 1001S02E05_string.py
# author by : Ž
text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases ar... |
7b459a585209d2029b1c52adf01a46aa21466ef8 | shen-huang/selfteaching-python-camp | /exercises/1901010056/1001S02E04_control_flow.py | 1,741 | 3.578125 | 4 | #for循环 "for" target_list目标列表 "in" expression_list表达式列表 ":" suite
# ["else" ":" suite] 当所有项被耗尽时,else 子句的子句体如果存在将会被执行,并终止循环。
#系统将为 expression_list 的结果创建一个迭代器,然后将为迭代器所提供的每一项执行一次子句体,具体次序与迭代器的返回顺序一致。
for i in range(1, 10): #对于表达式列表,中的1到9这九个数字,都会执行下面的子句体一次
for j in range(1, i+1): ... |
6eb50ecb0ef62ce2f1c44b7003f8fb3cb095e70a | shen-huang/selfteaching-python-camp | /exercises/1901100071/d08/mymodule/stats_word.py | 3,442 | 3.578125 | 4 | # 统计参数中每个英⽂单词出现的次数
def stats_text_en(text):
if not isinstance(text,str):
raise ValueError("参数必须是 str 类型,输入类型%s" % type(text))
elements = text.split()
words = []
symbols = ".*!'-"
for element in elements:
for symbol in symbols:
element = element.replace(symbol," ")
... |
41d47569fb8b5f72cd54a43f120ae84de2fef1c2 | shen-huang/selfteaching-python-camp | /19100401/Cyborg9999/d08/mymodule/stats_word.py | 3,532 | 3.6875 | 4 | text = '''
Alice was beginning to get very bored.She and her sister were sitting under the trees.
Her sisterwas reading,but Alice had nothing to do.Once or twice she looked into her sister's book,
but ithad no pictures or conversations in it.
爱丽丝开始觉得有点无聊了。她和姐姐正坐在树下。姐姐在看书,而爱丽丝无事可做。
她不时看看姐姐的书,里面既没有图画,也没有对话。
And what is... |
51573876385e465e13bfaeccba3edcc789cea3e7 | shen-huang/selfteaching-python-camp | /exercises/1901050107/1001S02E03_calculator.py | 395 | 4.03125 | 4 | # 简易计算器
a = int(input("请输入第一个数字: "))
b = int(input("请输入第二个数字: "))
c = input("请选择计算类别: A +、B -、C *、D / ")
if c == "A":
print("a + b = "+str(a + b))
elif c == "B":
print("a - b = "+str(a - b))
elif c == "C":
print("a * b = "+str(a * b))
elif c == "D":
print("a / b = "+str(a / b))
else:
print("运算符错误") ... |
ef37b04a9061626990eae77878c4e10af8cf1d0c | shen-huang/selfteaching-python-camp | /exercises/1901100020/1001S02E05_string.py | 1,994 | 4.09375 | 4 | # 1. 替换
# 定义text这个字符串
text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break ... |
980fe8f6a295963af56768a287d657edf998ea70 | shen-huang/selfteaching-python-camp | /exercises/1901050027/1001S02E04_control_flow.py | 412 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 14 15:25:41 2019
@author: PetalSaya
"""
def someFunction():
pass
for x in range (1,10):
for y in range (1, x+1):
if x==y:
print (x,"*",y,"=",x*y)
else:
print (x,"*",y,"=",x*y,end="\t")
i=1
while i<=9:
j=1... |
b98dd96d382380c116f3a7cabad53ba2215e4689 | shen-huang/selfteaching-python-camp | /19100401/yangxueximao/1001S01E05_string.py | 1,264 | 3.765625 | 4 | text='''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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases arent't special enough to break the rules.
Alth... |
fe8bb39685865ddcb69d2d9db16ae77c1ed1bdf0 | shen-huang/selfteaching-python-camp | /exercises/1901050074/1001S02E05_stats_text.py | 1,506 | 3.625 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although pr... |
609c90ce92347c0525602ec38130d4d27189e1d6 | shen-huang/selfteaching-python-camp | /exercises/1901040027/1001S02E05_string.py | 1,225 | 3.609375 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
A... |
448c5fb0d5657dc1bb38d5397fe8f4b3fbc67769 | shen-huang/selfteaching-python-camp | /exercises/1901010067/1001S02E03_calculator.py | 442 | 3.859375 | 4 | print('欢迎使用普通计算机')
print('-------------------')
while True:
num1 = float(input('输入数字按回车继续: '))
num2 = float(input('输入数字按回车计算: '))
print('和:' , num1+num2 ,)
print('差:' , num1-num2)
print('商:' , num1/num2 ,)
print('积:' , num1*num2)
print('-------------------')
end = input('请输入y退出计算机 ')
... |
7e5cb2c6d8705e160da2fa562ea6c0c8c9fccce4 | shen-huang/selfteaching-python-camp | /exercises/1901040030/1001S02E05_array.py | 367 | 3.71875 | 4 | list=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list.reverse() #反转列表
str1=''
for i in list:
str1=str1+str(i) #将列表里的数字转换成字符串
str2=str1[2:8] #截取第3到第8个字符
str3=str2[::-1] #反转字符串
num=int(str3) #将字符串转成int
num16=hex(num) #16进制
num8=oct(num) #8进制
num2=bin(num) #2进制
print(num,num16,num8,num2)
|
4d1de826ebc54e37cae4ebbe231ad3cd22be2a69 | shen-huang/selfteaching-python-camp | /19100301/cc-one/d5_exercise_array.py | 840 | 3.71875 | 4 | # cc-one 2019.3.28 数组操作,进制转换
#数组翻转 拼接成字符串 取出第三个到第8个字符 再次翻转 转化为int型 输出三种进制
# 定义原始数组
arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# 将数组翻转
arr.reverse()
#print('this is a reversed array: ',arr)
# 将翻转后的数组拼接成字符串
str1 = ''.join(str(i) for i in arr)
# 用字符串切片的方式取出第三个到第八个字符(包含第三和第八个字符)
str2 = str1[3:9]
# 将获得的字符串进行翻转
str3 = str2[::-1]
... |
8469b143c5e212ed867c7d2e3ad363145d7d78cb | shen-huang/selfteaching-python-camp | /exercises/1901100076/1001S02E04_control_flow.py | 538 | 3.875 | 4 | """
for a in range (1,10):
#print("第%d行"%a,end="\t")
for i in range(1,a+1):
print (a,'*',i,'=',a*i, end="\t")#end 表示用tab 结尾
print()#表示换行的功能
"""
"""
V1 之前出错尝试 cause:没有嵌套循环无法,继续执行
a=1
for i in range(1,a+1):
print (a,'*',i,'=',a*i, end="\t")
a=a+1
if a%2==0:
a=a+1
if a==10:
... |
7622552253b343fe3781a597c4eaf6616269f160 | shen-huang/selfteaching-python-camp | /exercises/1901100047/1901100047_calculator.py | 698 | 4.03125 | 4 | # Primitive Datatypes and Operators
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),type(a))
print('second_numbe... |
fdf72aa2843373ae8fe48c55f3b85923dab9d919 | shen-huang/selfteaching-python-camp | /19100302/catynchyna/d3_exercise_calculator.py | 1,850 | 4.3125 | 4 | # Please show users some of our friendly aura...
def welcome():
print("""\
Aloha, Welcome to Stitch Calculator!
""")
# how to set a function to call and restart again
# Define our function calculate()
def calculate():
operation = input("""\
Plese type in the math operation you want to conduct:
+ for Ad... |
19b202c3bcc3836f80c4004a0fd3d4204c7a234f | shen-huang/selfteaching-python-camp | /exercises/1901060011/1001S02E05_stats_text.py | 1,417 | 3.578125 | 4 | text = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Al... |
79605f949bc09573ab2e3d771616a6f1ce9069f3 | shen-huang/selfteaching-python-camp | /exercises/1901040017/1001S02E06_stats_word.py | 1,980 | 3.703125 | 4 | text1 = '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although p... |
429ec3fc535c0d850df496578e9e5dd436ec48b0 | shen-huang/selfteaching-python-camp | /exercises/1901010132/1001S02E06_stats_word.py | 2,972 | 4.0625 | 4 | #1.封装统计英文单词词频的函数
text1= '''
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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the r... |
aafa797eac49f6b48b8a9068d2baa4de9dadd832 | shen-huang/selfteaching-python-camp | /exercises/1901040006/1001S02E05_array.py | 726 | 3.515625 | 4 | array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
#2. 将数组 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 翻转
array.reverse()
#3. 翻转后的数组拼接成字符串
array_s1 = ''
for i in array:
array_s1 = array_s1 + str(i)
#4. ⽤字符串切⽚的⽅式取出第三到第⼋个字符(包含第三和第⼋个字符)
array_s2 = array_s1[2:8]
#5. 将获得的字符串进⾏翻转
array_s3 = array_s2[::-1]
#6. 将结果转换为 int 类型
array_s4 = int(ar... |
20e62c652f3da3b4d4648a01ce43cb61d1002a2a | shen-huang/selfteaching-python-camp | /19100305/luokaiwen1022/d3_exercise_calculator.py | 1,490 | 3.890625 | 4 | # This is d3_exercise_calculator.py
import string
# this is def of add, sub, mul, div, pow
def add(a,b):
return a + b
def sub(a,b):
return a - b
def mul(a,b):
return a * b
def div(a,b):
if b == 0:
return "Dividend can't be zero.Please input again."
else:
return a / b
def pow(a,b):
... |
5c0fb4125ee03c7a68fd502c9efc1cbfcb02a65d | shen-huang/selfteaching-python-camp | /exercises/1901050047/1001S02E05_string.py | 2,194 | 3.890625 | 4 | # 1.将better全部替换成worse
# 2.将字符串样本text里英文单词中包含ea的英文单词剔除
# 3.大写字母转成小写,小写字母转成大写
# 4.将所有单词按a...z升序排列
# 5.最后输出结果
text = '''
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.
Flat is better than nested.
Sparse... |
032bb9960a355672c1e3636db3a6b6b0daf96321 | shen-huang/selfteaching-python-camp | /exercises/1901040047/1001S02E04_control_flow.py | 395 | 3.796875 | 4 | print('《九九乘法表》')
for i in range(1,10):
for j in range(1,i+1):
print(j,"*",i,"=",i*j,end='\t')
print('')
print("\n《九九乘法表-奇数行》")
for x in range(1, 10):
for y in range(1, x+1):
while x % 2 != 0:
print(y, 'x', x, '=', x*y, end='\t')
if x == y:
... |
665d56cbcd340f3227667680ddfbeb5bd4485f50 | shen-huang/selfteaching-python-camp | /19100205/Ceasar1978/d3_exercise_calculator.py | 871 | 4.3125 | 4 | # 定义函数
def add(x,y):return x+y
def abstract (x,y):return x-y
def multiply (x,y):return x*y
def divide (x,y):return x/y
# 用户输入
for print("""
请输入您需要执行的运算:
1:加法
2:减法
3:乘法
4:除法
""")
# 运行计算
choice = input("请输入您需要执行的运算(1/2/3/4):")
num1 = int(input("第一个数字:"))
... |
478e3bc14396fc53bf3513c4f6fe3626c1279e0d | shen-huang/selfteaching-python-camp | /exercises/1901040043/1001S02E04_control_flow.py | 684 | 3.640625 | 4 |
for i in range(10): #打印九九乘法表
s=''
for j in range(1,i+1):
s+=str(j)+'*'+str(i)+'='+str(j*i)+'\t'
print(s)
f=1 #九九乘法表去偶数行
while f<=9:
if f%2!=0:
h=1
while h<f+1:
print(f,"*",h,'=',f*h,sep='',end='\t')
h+=1
print()
f+=1
f=1 ... |
b1df58dd8fdf106ad819c913e0956357c22cf161 | shen-huang/selfteaching-python-camp | /exercises/1901050070/1001S02E04_control_flow.py | 308 | 3.75 | 4 |
for i in range(1,10):
for n in range(1,i+1):
print(i,"*",n,"=",eval('n*i'),'',end="")
print()
i = 1
while i <= 9:
n = 1
while n <= i:
if i % 2 != 0:
print(i,"*",n,"=",eval('n*i'),'',end="")
n += 1
i += 1
if i % 2 == 0:print()
|
1f728eb0b3aba306d3bfd5bd48c45476ceee01e6 | shen-huang/selfteaching-python-camp | /19100302/boy88/d4_exercise_control_flow.py | 443 | 3.78125 | 4 | #方法一
print("<<九九乘法表>>")
for i in range(1,10):
for x in range(1,i+1):
print( '%d X %d = %2d' % (i ,x ,i*x) ,end = ' ' )
print(' ')
#
print('-----------------------------------------------')
print("this is a new test3")
i = 1
while i < 10:
if i % 2 == 0:
i += 1
continue
j = 1
... |
35affbce581f814c44b111e02c9ef78e6fe07b7b | shen-huang/selfteaching-python-camp | /exercises/1901100020/1001S02E05_array.py | 1,249 | 3.953125 | 4 | # 列表也可以叫数组
# 1.对列表进行翻转
sample_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
reversed_list = sample_list[::-1]
print('列表翻转 ==>',reversed_list)
# 2.翻转后的列表拼接成字符串
# 调用''(空字符串)str类型的join方法可以连接列表里的元素,用''(空字符串)表示连接的时候元素间不用任何字符隔开
# 因为reverd_list 里面都是int类型元素,所以拼接之前要把reversed_list变成一个包含str类型元素的列表
joined_str = ''.join([str(i) for i in r... |
d785a7ee94c28b99904d27fd542db03995752cc5 | shen-huang/selfteaching-python-camp | /exercises/1901100167/1001S02E05_string.py | 1,189 | 3.875 | 4 | text = r'''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.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Alt... |
3edcf96e22715f6aefb064ca0b5dab7f00c4fc09 | shen-huang/selfteaching-python-camp | /exercises/1901020006/1001S02E06_stats_word1.py | 1,932 | 3.546875 | 4 | # 封装统计英文单词词频的函数
# 1定义一个名为 stats_text_en 的函数
def stats_text_en(text):
if not isinstance(text,str):
return '请输入字符串'
# 2.统计参数中每个英文单词出现的次数
# 3.替换掉所有的符号
text1 = text.replace(',','').replace('.','').replace('--','').replace('!','').replace('*','')
# 4.按照空格把所有单词分隔开
text2 = text.split()
... |
114492a01d99c923cf8f258a3e9b78f1b40d1da5 | shen-huang/selfteaching-python-camp | /19100401/congboqiu/d4_exercise_control_flow.py | 598 | 3.8125 | 4 | print('用for...in编九九乘法表')
for i in range(1,10):
for j in range(1,i+1):
print(i,'*',j,'=',i*j,end=' ')#print默认是打印一行,结尾加换行。end=' '意思是末尾不换行,加空格。
if i == j: #当i等于j的时候,
print()#换行。
print('用while编去偶数行的九九乘法表')
i=0
j=0
while i<9:
i+=1
if i%2==0:
continue#i为偶数是不执行后续循环代码
... |
e3fd07d0ab9343ed95f690f8ad81ae2694a96335 | shen-huang/selfteaching-python-camp | /exercises/1901050024/1001S02E05_array.py | 545 | 3.625 | 4 | data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] #创建数组
data.reverse() #将数组翻转
data_string = ''
for i in data:
data_string += str(i)
data_part = data_string[2:8] #取出3-8个字符
data_part = data_part[::-1] #字符翻转
data_part = int(data_part) #转成int类型
print('二进制... |
91cce7494e17c26ab826b5ebc9fe1f2ac15415d3 | shen-huang/selfteaching-python-camp | /exercises/1901100076/1001S02E03_calculator.py | 609 | 4.28125 | 4 | #计算器支持加减乘除
operator= input("pls input character (+,-,*,/):")#()内内容为提示内容
firstnumber=input("first number:")
secondnumber=input("second number:")
a=float(firstnumber)
b=float(secondnumber)
print("operator:",operator,type(operator))
print("first_number:",firstnumber,type(firstnumber),type(a))
print("second_number:",seco... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.