Question: Convert the matlab code to python code : tic; h=waitbar(0,'Please wait..'); m_5 = 100000; N = 1000; matched = 0; hackerList_5 = zeros(m_5,1); hackerPassword_5 =
Convert the matlab code to python code :
tic;
h=waitbar(0,'Please wait..');
m_5 = 100000;
N = 1000;
matched = 0;
hackerList_5 = zeros(m_5,1);
hackerPassword_5 = zeros(1,4);
for k=1:1:m_5
waitbar(k/m_5)
result = strcat(num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))));
result = str2num(result);
hackerList_5(k) = result;
end
for f = 1:N
waitbar(f/N)
result = strcat(num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))),num2str(ceil(randi([1,26],1,1))));
userPassword_5 = str2num(result);
for q = 1:m_5
if hackerList_5(q) == userPassword_5(1)
matched = matched +1;
break;
end
end
end
p_5 = matched/N
close(h);
toc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
