def trans(n):
if n <= 1:
return str(n)
else:
return trans(n // 2) + str(n % 2)
print(trans(13))
def toStr(n,base):
s = "01"
if n < base:
return s[n]
return ①
n = int(input('请输入正整数:'))
result = toStr(n,2)
print(result)
则代码中①处的语句可为( )
def f(s):
if len(s)==1:
return True
elif len(s)==2:
return s[0]==s[l]
elif s[0]==s[-l]:
return f(s[l:-l])
return False
print(f("1234321"))
执行该程序段后,下列说法正确的是( )
a=5
if (a>3) and ((a==4) or (a<6)):
print("Hello")
print("Bye")
运行结果是: (提示:输入宇母时只能输入小写字母)
图 a
图 b
请回答下列问题:
f=open(" ",encoding="utf-8")
line=f.readline() #读取第一行,保存在字符串 line 中
pro,pub=0,0
while line:#当 line 非空
x=
t=int(line[3:])
if x=="A":
pro+=t
elif x=="B":
line=f.readline() # 继续读取一行
score=int(pro/5*0.6+pub/5*0.4)
grade=
print("推荐度为:","★"*grade)
n=int(input("请输入要查找的自幂数位数:"))
count=total=0
for i in range(1*10**(n-1),1*10**n):
a=i
while a>0:
total+=
a=a//10
if i==total:
count+=1
print(i)
print(str(n)+"位自幂数一共有"++"个")
f=open("dc.txt",encoding="utf-8")
line=f.readline()
# 读取第一行,保存在字符串 line 中
while line: # 当 line 非空