到目前为止,我已经做到了。我被困在递归上。我不知道如何前进,加入和逆转等。
def callrecursion(s):
a=s.index('(')
z=len(s) - string[::-1].index(')') -1
newStr=s[a+1:z]
# Something is missing here i cant figure it out
print(newStr)
return newStr
def reverseParentheses(s):
if '(' in s:
return reverseParentheses(callrecursion(s))
print('wabba labba dub dub')
else:
return s
string='a(bcdefghijkl(mno)p)q'
reverseParentheses(string)
Run Code Online (Sandbox Code Playgroud)
预期的输出:“ apmnolkjihgfedcbq”
尝试使用django中的shell删除对象。如何删除显示“ Ron”的对象?
我使用以下命令:
t.delete('Ron')
Run Code Online (Sandbox Code Playgroud) 我必须将月份名称显示为 xticks,当我绘制图形并将 x 作为月份名称传递时,它会绘制错误。我还必须在线图上叠加散点图。
我无法在此处粘贴完整的代码,因为它是 MOOC 作业,我只是在寻找我在这里做错了什么。
plt.figure(figsize=(8,5))
plt.plot(mint['Mean'],linewidth= 1, label = 'Minumum')
plt.plot(maxt['Mean'],linewidth = 1, label = 'Maximum')
plt.scatter(broken_low,mint15.iloc[broken_low]['Mean'],alpha = 0.75)
plt.scatter(broken_high,maxt15.iloc[broken_high]['Mean'],alpha = .75)
Run Code Online (Sandbox Code Playgroud)
数据集链接在这里:
https://drive.google.com/file/d/1qJnnHDK_0ghmHQl4OuyKDr-0K5ETo7Td/view?usp=sharing
它应该看起来像这样,填充线之间的面积,x 轴为月份,y 轴为摄氏度
我sum()在循环中使用,执行时间超过4s,sum()这里是否等于嵌套循环?
def arrayMaxConsecutiveSum(inputArray, k):
cop=k
lis=[]
i=0
while i < len(inputArray):
inpu=sum(inputArray[i:cop])
lis.append(inpu)
cop+=1
i+=1
return max(lis)
Run Code Online (Sandbox Code Playgroud)