1.IP地址转换I
ip=input()
if len(ip)==32 and set(ip)<={'0','1'}:
print('.'.join([ str(int(ip[8*i:8*(i+1)],2)) for i in range(4)]))
else:
print('data error!')
2.找数字,做加法
a=input()
b=input()
d1=''
d2=''
for i in a:
if i.isnumeric():
d1+=i
for i in b:
if i.isnumeric():
d2+=i
print('{}+{}={}'.format(d1,d2,eval(d1)+eval(d2)))
3.找“与7相关的数”
n=eval(input())
I=[]
for i in range(1,n):
if i%7==0 or '7' in str(i):
I.append(i)
print("与7相关的数共有: {}".format(len(I)))
print("与7相关的数: {}".format(I))
4.通讯录的名单
a=input().split(',')
a1=list(set(a)) #先集合,再列表,因为集合无序,所以顺序会乱
print(sorted(a1,key=a.index)) # 排序
5.
import string
a=input()
for i in string.punctuation:
a=a.replace(i,' ')
b=a.lower().split()
dict={}
for key in b:
dict[key]=dict.get(key,0)+1
print(dict)