我想知道如何用基本的Python(不使用库)解决这个问题:How can Icalculate When one's 10000 day after thebirth will (/would be)?
例如,给定星期一 19/05/2008,所需的日期是星期五 05/10/2035(根据https://www.durrans.com/projects/calc/10000/index.html?dob=19%2F5% 2F2008&e=mc2 )
到目前为止我已经完成了以下脚本:
years = range(2000, 2050)
lst_days = []
count = 0
tot_days = 0
for year in years:
if((year % 400 == 0) or (year % 100 != 0) and (year % 4 == 0)):
lst_days.append(366)
else:
lst_days.append(365)
while tot_days <= 10000:
tot_days = tot_days + lst_days[count]
count = count+1
print(count)
Run Code Online (Sandbox Code Playgroud)
它会估计该人生日 10,000 天后的年龄(对于 2000 年之后出生的人)。但我该如何继续呢?
我是Matlab的新手.在Python中,可以方便地交换元素.
x,y = 5,10
x,y = y,x
Matlab(或Octave/Scilab)中有类似的东西吗?否则,在不使用临时变量的情况下交换元素的最佳方法是什么?
在Mathematica中,可以从例如List执行命令开始获取所有内置函数的名称
Names["List`*"]
Run Code Online (Sandbox Code Playgroud)
此外
Names["context`*"]
Run Code Online (Sandbox Code Playgroud)
列出指定上下文中的所有符号.例如
Names["Global`*"]
Run Code Online (Sandbox Code Playgroud)
给出所有内置符号的名称(以及用户在全局上下文中定义的符号,如果有的话).
Matlab/Octave中是否有类似的结构?
我在Octave,Scilab和Matlab提示符下测试以下命令.
>> A = rand(10000,10000);
>> B = rand(10000,1);
>> tic,A\B;, toc
Run Code Online (Sandbox Code Playgroud)
时间分别为40,15.8和15.7秒.为了比较,Mathematica的表现是
In[7]:= A = RandomReal[{0, 1}, {10000, 10000}];
In[9]:= B = RandomReal[{0, 1}, 10000];
In[10]:= Timing[LinearSolve[A, B];]
Out[10]= {14.125, Null}
Run Code Online (Sandbox Code Playgroud)
这是否表明Octave不如线性方程领域的其他软件那么强大?