首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

PTA-浙大版《Python 程序设计》AC解答汇总-第三章

  • 24-03-02 23:55
  • 2635
  • 12577
blog.csdn.net
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
# 第3章-1 3-1.大于身高的平均值 (10分) 
def demo_3_1():
    h=list(map(int,input().split()))
    ave=sum(h)/len(h)
    for x in h:
        if x > ave:
            print(x,end=" ")


# 第3章-2 查验身份证 (15分)
def demo_3_2():
    n=int(input())
    W=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    M="10X98765432"
    res=[]
    for i in range(n):
        s=input()
        sum,flag=0,0
        for j in range(17):
            if s[j].isdigit():
                sum=sum+int(s[j])*W[j]
            else:
                flag=1
                break
        if(M[sum%11]!=s[17]) or flag==1:
            res.append(s)
    if len(res):
        for x in res:print(x)
    else:
        print("All passed")

                                
# 第3章-3 输出字母在字符串中位置索引 (20分)
def demo_3_3():
    str=input()
    s,p=input().split()
    for i in range(len(str)-1,0,-1):
        if str[i]==s or str[i]==p:
            print("%d %c"%(i,str[i]))
  
                                
# 第3章-4 查找指定字符 (15分)
def demo_3_4():
    s=input()
    str=input()
    if str.rfind(s)!=-1:
        print("index = %d"%(str.rfind(s)))
    else:
        print("Not Found")

                                
# 第3章-5 字符转换 (15分)
def demo_3_5():
    str=input()
    res=""
    for x in str:
        if x.isdigit():
            res=res+x
    print(int(res))


# 第3章-6 求整数序列中出现次数最多的数 (15分)
def demo_3_6():
    nums=list(map(int,input().split()))
    num,cnt=0,0
    for x in nums[1:nums[0]+1]:
        if nums.count(x)>cnt:
            num=x
            cnt=nums.count(x)
    print(num,cnt)


# 第3章-7 求最大值及其下标 (20分)
def demo_3_7():
    N=int(input())
    nums=list(map(int,input().split()))
    max=max(nums[0:N+1])
    for i in range(N):
        if nums[i]==max:
            print(max,i)
            break
                    
                               
# 第3章-8 字符串逆序 (15分)
def demo_3_8():
    str=input()
    print(str[::-1])


# 第3章-9 字符串转换成十进制整数 (15分)
def demo_3_9():
    nums="0123456789abcdefABCDEF-"
    str=input()
    num=""
    for x in str:
        if x in nums:
            num=num+x
        elif x==" ":
            break
    if num=="" or num=="-":
        print(0)
    elif num[0]=="-":
        print(-int(num.replace("-",""),16))
    else:
        print(int(num.replace("-",""),16))


# 第3章-10 统计大写辅音字母 (15分)
def demo_3_10():
    C="BCDFGHJKLMNPQRSTVWXYZ"
    str=input()
    cnt=0
    for x in str:
        if x in C:
            cnt=cnt+1
    print(cnt)


# 第3章-11 字符串排序 (20分)
def demo_3_11():
    strings=input().split(" ")
    strings.sort()
    print("After sorted:")
    for x in strings:
        print(x)


# 第3章-12 求整数的位数及各位数字之和 (15分)
def demo_3_12():
    num=input()
    print(len(num),sum(int(x) for x in num))


# 第3章-13 字符串替换 (15分)
def demo_3_13():
    s=input()
    for x in s:
        if x>="A" and x<="Z":
            print(chr(ord("A")+ord("Z")-ord(x)),end="")
        else:
            print(x,end="")

                                  
# 第3章-14 字符串字母大小写转换 (15分)
def demo_3_14():
    s = input()
    for x in s:
        if x==" ":
            break
        elif x.islower():
            print(x.upper(),end="")
        elif x.isupper():
            print(x.lower(),end="")
        else:
            print(x,end="")


# 第3章-15 统计一行文本的单词个数 (15分)
def demo_3_15():
    s=input().split(" ")
    print(len([x for x in s if x !=""]))


# 第3章-16 删除重复字符 (20分)
def demo_3_16():
    str=list(set(input()))
    print("".join(sorted(str)))

                                
# 第3章-17 删除字符 (30分)
def demo_3_17():
    s1,s2 = input().strip(),input().strip()
    print("result:",s1.replace(s2.upper(), '').replace(s2.lower(), ''))


# 第3章-18 输出10个不重复的英文字母 (30分)
def demo_3_18():
    str=input()
    res=""
    for x in str:
        if x not in res and x.isalpha() and x.upper() not in res.upper():
            res=res+x
        if len(res)>=10:
            break
    if len(res)<10:
        print("not found")
    else:
        print(res)


# 第3章-19 找最长的字符串 (15分)
def demo_3_19():
    n=int(input())
    longest=""
    for i in range(n):
        str=input()
        if len(str)>len(longest):
            longest=str
    print("The longest is:",longest)


# 第3章-20 逆序的三位数 (10分)
def demo_3_20():
    print(int(input()[::-1]))


# 第3章-21 判断回文字符串 (15分)
def demo_3_21():
    str=input()
    print(str)
    if str==str[::-1]:
        print("Yes")
    else:
        print("No")


# 第3章-22 输出大写英文字母 (15分)
def demo_3_22():
    str=input()
    res=""
    for x in str:
        if x.isupper() and x not in res:
            res=res+x 
    if len(res)>0:
        print(res)
    else:
        print("Not Found") 


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
注:本文转载自blog.csdn.net的邂逅模拟卷的文章"https://blog.csdn.net/qq_34451909/article/details/107982811"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

101
推荐
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2025 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top