赞
踩
@abc.com
123ok
_xiaoming
Xiaoming_$
interface
sina@163
r=float(input("请输入圆的半径(不含面积单位的纯数值):"))
per = 2*3.14159*r
area = 3.14159*(r**2)
print("该圆周长为:%s,面积为:%s"%(per,area))
vel = 40.0
dis = 45678.9
time = float(dis/vel)
print(str(time)+"时")
num = 1
while num==1:
num1 = int(input("请输入第一个数:"))
num2 = int(input("请输入第二个数:"))
if num1>num2:
print(num1)
num = 0
elif num1 == num2:
print("输入的两个数字一样大,请重新输入")
num = 1
elif num1<num2:
print(num2)
num = 0
num = 1 while num == 1: num1 = int(input("请输入第一个数:")) num2 = int(input("请输入第二个数:")) num3 = int(input("请输入第三个数:")) if num1 > num2: if num1 > num3: print(num1) num = 0 elif num1 == num3: print("第一次和第三次输入的数字一样大,请重新输入") num = 1 elif num1<num3: print(num3) num = 0 elif num1 == num2: print("第一次和第二次输入的数字一样大,请重新输入") num = 1 elif num1<num2 and num1 != num3: if num2 > num3: print(num2) num = 0 elif num2 == num3: print("第二次和第三次输入的数字一样大,请重新输入") num = 1 elif num2<num3: print(num3) num = 0 elif num1 == num3: print("第一次和第三次输入的数字一样大,请重新输入") num = 1
&
num1 = int(input("请输入第一个数:"))
num2 = int(input("请输入第二个数:"))
num3 = int(input("请输入第三个数:"))
num4=max(num1,num2,num3)
print(num4)
num1 = input("请输入一个三位数:")
num2 = int(num1[0])
num3 = int(num1[1])
num4 = int(num1[2])
print(num2,num3,num4)
if int(num1) == num2**3 + num3**3 + num4**3:
print("您输入的:%s是水仙花数"% num1)
elif int(num1) != num2**3 + num3**3 + num4**3:
print("您输入的:%s不是水仙花数" % num1)
num = 1 while num == 1: num1 = input("请输入一个五位数:") if len(num1) != 5: print("您输入的不是五位数!请重新输入") num = 1 elif len(num1) == 5: num2 = num1[::-1] # print(num2) #检查num2格式 if num1 == num2: print("您输入的是回文数") num = 0 elif num1 != num2: print("您输入的不是回文数") num = 0 continue
num = input("请输入一个字符串:")
res = num.swapcase()
print(res)
num = input("请输入一个字符串:")
print(num.swapcase())
num = input("请输入一个字符串:")
print(len(num))
num = input("请输入一个字符串:")
print(num.title())
str = input("请输入一个字符串")
num = str.count()
print(num)
import itertools
l = [(k,len(list(g))) for k, g in itertools.groupby('aaabcaaddbbc')]
print(l)
s = ''
for i in l:
if i[1] != 1:
s += str(i[1])
s += str(i[0])
print(s)
&
pro = input() string = input() n = len(string) ans = "" # 输出结果 if pro == "C": # 压缩 i = 0 while i < n: # 从i 开始寻找连续相同的字符,计数为con j = i + 1 con = 1 while j < n and string[j] == string[i]: con += 1 j += 1 if con == 1: # 计数为1 则直接加到ans ans = ans + string[i] else: new = "%d%s" % (con, string[i]) ans = ans + new i = j # i 定位到下一个字符 else: # 解压 i = 0 while i < n: j = i + 1 if string[i].isdigit(): # 从i 开始寻找连续的数字字符,为数量num while string[j].isdigit(): j += 1 num = int(string[i:j]) new = string[j] * num ans = ans + new i = j + 1 else: # 若i 不为数字,直接添加到ans ans = ans + string[i] i = j print(ans)
&
strinput = input("请输入字符串:") i = 0 count = 1 output = [] while i < len(strinput): if i + 1 == len(strinput): output.append(strinput[i]) output.append(str(count)) break if strinput[i] == strinput[i + 1]: count += 1 else: output.append(strinput[i]) output.append(str(count)) # 重新赋值 count = 1 # 累计 i += 1 print("".join(output))
num = input("请输入一个字符串:")
print(num.strip("123"))
strs = input("请输入一个字符串:")
for s in strs:
# 小写的十进制范围97--122 大写的范围65-90
if ord(s) in range(97,123):
print(chr(ord(s)-32),end="")
elif ord(s) in range(65,91):
print(chr(ord(s) + 32),end="")
else:
print(s,end="")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。