python小练习

python小练习_第1张图片

 

'''
#第一题
def sum1(str):

sum=0
for x in str:
sum=sum+x
return sum
if __name__ == '__main__':
x=input("请输入一个整型字符串:")
lst=[int(i) for i in x]
print(sum1(lst))'''
'''
#第二题
str=input("请输入一个字符串:")
print(str[::-1])'''
'''
#第三题
def max1(a):
m=a[0]
for x in a:
if x>m:
m=x
return m
if __name__ == '__main__':
x=input("请输入一个整数列表,用空格隔开:").split()
lst=[int(i) for i in x]
print(max1(lst))'''
'''
#第四题
lst4=input().split(",")
newlst2=[]
for i in lst4:
newlst2.append(i)
print(newlst2)'''
'''
#第五题
lst3=input().split(",")
newlst3=[]
for x in lst3:
if x=='0':
continue
if x=='None':
continue
if x=='False':
continue
else:
newlst3.append(x)
print(newlst3)'''
'''
#第六题
x=input().split(",")
lst=[int(i) for i in x]
count=0
sum=0
for i in lst:
count=count+1
sum=sum+i
svr=sum/count
print("平均数为{:.3f}".format(svr))'''
'''#第七题
x=input().split(",")
lst=[int(i) for i in x]
lst.sort(reverse=True)
print(lst)'''
'''#第八题
x=input().split(",")
lst=[str(i) for i in x]
for i in range(len(lst)):
lst[i]=len(lst[i])
print(lst)'''
'''#第九题
x=input().split(",")
lst=[int(i) for i in x]
m=lst[0]
for i in lst:
if abs(i)>abs(m):
m=i
print(m)'''
'''#第十题
s=input("输入任意数据:")
t=[int(n) for n in s.split(',')]
a=1
for i in range(len(t)):
a*=t[i-1]
print("乘积为{}".format(a))'''
'''#第十一题
s=input("输入一组数据:")
t=[int(n) for n in s.split(',')]
a=input("输入与上组数据等长的数据:")
b=[int(n) for n in s.split(',')]
for i in range(len(t)):
t[i]=t[i]*b[i]
print("两个向量的内积为:",t)'''

 

 

 

 

 

'''
#第一题
def sum1(str):

sum=0
for x in str:
sum=sum+x
return sum
if __name__ == '__main__':
x=input("请输入一个整型字符串:")
lst=[int(i) for i in x]
print(sum1(lst))'''
'''
#第二题
str=input("请输入一个字符串:")
print(str[::-1])'''
'''
#第三题
def max1(a):
m=a[0]
for x in a:
if x>m:
m=x
return m
if __name__ == '__main__':
x=input("请输入一个整数列表,用空格隔开:").split()
lst=[int(i) for i in x]
print(max1(lst))'''
'''
#第四题
lst4=input().split(",")
newlst2=[]
for i in lst4:
newlst2.append(i)
print(newlst2)'''
'''
#第五题
lst3=input().split(",")
newlst3=[]
for x in lst3:
if x=='0':
continue
if x=='None':
continue
if x=='False':
continue
else:
newlst3.append(x)
print(newlst3)'''
'''
#第六题
x=input().split(",")
lst=[int(i) for i in x]
count=0
sum=0
for i in lst:
count=count+1
sum=sum+i
svr=sum/count
print("平均数为{:.3f}".format(svr))'''
'''#第七题
x=input().split(",")
lst=[int(i) for i in x]
lst.sort(reverse=True)
print(lst)'''
'''#第八题
x=input().split(",")
lst=[str(i) for i in x]
for i in range(len(lst)):
lst[i]=len(lst[i])
print(lst)'''
'''#第九题
x=input().split(",")
lst=[int(i) for i in x]
m=lst[0]
for i in lst:
if abs(i)>abs(m):
m=i
print(m)'''
'''#第十题
s=input("输入任意数据:")
t=[int(n) for n in s.split(',')]
a=1
for i in range(len(t)):
a*=t[i-1]
print("乘积为{}".format(a))'''
'''#第十一题
s=input("输入一组数据:")
t=[int(n) for n in s.split(',')]
a=input("输入与上组数据等长的数据:")
b=[int(n) for n in s.split(',')]
for i in range(len(t)):
t[i]=t[i]*b[i]
print("两个向量的内积为:",t)'''

 

 

 

 

 

 

 

 

 

 

 

 

 

 




 

 

 

 

 

 

 

 

 

 




你可能感兴趣的:(python小练习)