format() 格式化函数
python 保留两位小数
python中join()函数的使用方法 //排序–合成新字符串
Python字符串排序的两种方法详解
A - A+B Problem—1000
st=input().split();
a=int(st[0]);
b=int(st[1]);
print(a+b);
B - A+B for Input-Output Practice (I)—1010
while True:
try:
st=input().split();
s=int(st[0])+int(st[1]);
print(s);
except:
break;
while True:
try:
st=input().split();
b=list(map(int,st));
print(sum(b));
except:
break;
C - A+B for Input-Output Practice (II)—1011
n=int (input());
for i in range (n):
x1=input().split();
x=list(map(int ,x1));
print(sum(x));
D - A+B for Input-Output Practice (III)—1012
while True:
x=input().split();
a=int(x[0]);
b=int(x[1]);
if(a==0) and (b==0) :break;
print(a+b);
E - A+B for Input-Output Practice (IV)—1013
while True:
x=input().split();
x1=list(map(int,x));
if x1[0]==0:
break;
print(sum(x1)-x1[0]);
while True:
x=input().split();
x1=list(map(int,x));
if x1[0]==0:
break;
s=0;
for i in range (x1[0]):
s=x1[i+1]+s;
print(s);
F - A+B for Input-Output Practice (V)—1014
n=int(input());
for i in range(n):
x=input().split();
x1=list(map(int ,x));
print(sum(x1)-x1[0]);
G - A+B for Input-Output Practice (VI)—1015
while True:
try:
n=input().split();
x1=list(map(int ,n));
print(sum(x1)-x1[0]);
except:break
H - A+B for Input-Output Practice (VII)—1016
while True:
try:
n=input().split();
x1=list(map(int,n));
print(sum(x1));
print();
except:break
I - A+B for Input-Output Practice—1017
n=int(input());
for i in range(n):
x=input().split();
x1=list(map(int ,x));
print(sum(x1)-x1[0]);
print();
J - 分数的化简—
import fractions
f1=input()
f=fractions.Fraction(f1);
print(f);
N - ASCII码排序
while True:
try:
x = input()
l = list(x)
l.sort();
s = " ".join(l);
print(s);
except:
break;
O - C语言实验——温度转换
x=input();
y=float(5*(float(x)-32)/9)
print("{:.2f}".format(y));
P - C语言实验——逆置正整数
x=input();
x1=int (x);
y1=x1%10;
y2=int (x1/10%10);
y3=int(x1/100);
print(y1*100+y2*10+y3)
while True:
try:
x=float(input());
y=4/3*pow(x,3)*3.1415927
print("{:.3f}".format(y))
except:
break;
Q - 计算球体积
while True:
try:
x=float(input());
y=4/3*pow(x,3)*3.1415927
print("{:.3f}".format(y))
except:
break;
R - 求班级男女生比例
while True:
try:
x = input().split();
x1 = list(map(int, x));
xx = float(x1[0] / (x1[0] + x1[1]));
yy = float(x1[1] / (x1[0] + x1[1]));
print("{:.2f}".format(xx * 100) + "%", "{:.2f}".format(yy * 100) + "%")
except:
break;
S - 直角坐标系
while True:
try:
st=input().split();
x=list(map(int ,st));
if x[0]<0 and x[1]<0 :print("3");
if x[0]>0 and x[1]>0 :print("1");
if x[0]>0 and x[1]<0 :print("4");
if x[0]<0 and x[1]>0 :print("2");
except:
break;