赞
踩
- # 请在此添加代码
- ########## Begin ##########
- s = input("Please Input:")
- lst = []
- for ch in s:
- if ch not in lst:
- lst.append(ch)
- print(lst)
- ########## End ##########
- # 请在此添加代码
- ########## Begin ##########
- s = input('please input a list:')
- s = eval(s)
- print('变换前,s=', s)
- for i in range(len(s)):
- if s[i] % 2 == 0:
- s[i] = s[i] ** 2
- print('变换后,s=', s)
-
- ########## End ##########
第3关:求ASCII
- # 请在此添加代码
- ########## Begin ##########
- s = input('请输入一个字符串:')
- list = []
- for i in s:
- list.append(ord(i))
- print(list)
-
- ########## End ##########
- # 请在此添加代码
- ########## Begin ##########
- # 输入数据个数
- n = int(input('输入数据个数:'))
-
- # 创建一个空列表
- x = []
-
- # 循环读入n个数到列表
- for i in range(n):
- a = int(input('输入一个数:'))
- x.append(a)
-
- # 使用简单交换排序法对x排序
- for i in range(n - 1):
- for j in range(i + 1, n):
- if x[i] > x[j]:
- x[i], x[j] = x[j], x[i]
-
- # 输出排序后的结果
- print('排序后数据:', x)
-
- ########## End ##########
- # 请在此添加代码
- ########## Begin ##########
- list_str = input()
- lst = sorted(list(set(map(int, list_str.strip('()').split(',')))))
-
- x = int(input("输入待查数据:"))
-
- low = 0
- high = len(lst) - 1
- found = False
-
- while low <= high and not found:
- mid = (low + high) // 2
- if lst[mid] == x:
- found = True
- else:
- if x < lst[mid]:
- high = mid - 1
- else:
- low = mid + 1
-
- if found:
- print("已找到", x)
- else:
- print("未找到", x)
-
-
- ########## End ##########
- # 请在此添加代码
- ########## Begin ##########
- # 输入矩阵的行数和列数
- m, n = map(int, input("请输入行数和列数,以,隔开:").split(","))
- matrix = []
- for i in range(m):
- row = []
- # 输入矩阵的一行数据,用列表表示
- for j in range(n):
- x = int(input())
- row.append(x)
- matrix.append(row)
- for i in range(m):
- # 求出一行的最大值及其列号
- max_val = max(map(abs, matrix[i]))
- max_col = matrix[i].index(max_val)
- # 输出行号、列号、最大值
- print(i, max_col, max_val)
-
-
-
-
- ########## End ##########
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。