Why does the 'turtle star' in docs.python.org not work? - python-turtle

I want to learn turtle from https://docs.python.org/3/library/turtle.html, but I find something different from the example there.
Here is the example image:
example
and the code:
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
I run the code above in my machine, but I get this:
my result.
I want to know why I can't get the example's result, and how to draw the same image.

Related

Follow/Highlight signal path after Simulation (Matlab Simulink)

I have a model which looks like this :
In Equipement2 block for example :
In ETAFON1 block for example :
In this example i have only put 2 variable "true" (to make equipement2 red) and i would like to know if it's possible to follow/highlight the path of the signals which started from "true" variable or to know why an equipement is red by following the signal in reverse direction at the end of the Simulation like a recap of the signal ?

lua - loadfile is executing right away and i can't figure out why

I was under the impression that doing something like this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))('13')
would just load the contents of widgetlookup.lua into the variable "f" and then to run the code, i could do this:
f()
However, what's happening is that as soon as I load the file, it's executing. I know because widgetlookup.lua prints out a string with the results. Ultimately, I need to capture the results of the script in a variable
Can you tell me what I'm doing wrong? If you need to see the contents of widgetlookup.lua please just say the word and i will post. Just didn't want to clutter up the question with unnecessary information.
Thanks.
EDIT 1
I changed my code to look like this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))
local p = f(13)
And now code waits to run until i hit the second line... but I need to know how to capture the output of the script as a variable....
print(p) current returns a null value.
You're calling it with that ('13') at the end.
You want this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))

wxMaxima: how to get decimal number results?

This should be easy but I am struggling on that.
I googled already but nothing seems to work.
(I am using wxMaxima 15.08.1 on Windows)
My example code looks like this:
kill (all);
numer:true;
sigma_z: 1000.0$ /*[N/mm²]*/
sigma_b_zul : simga_z*0.7;
sigma_b_zul : simga_z*0.7, numer;
sigma_b_zul : simga_z*0.7, numer:true;
float(sigma_b_zul);
the output is every time:
0.7 simga_z
the next cell looks like:
d_d: 1000$ /*dfd*/
sigma_g_f_d: d_d * 0.7;
the result is:
7.0E+2
I am completely clueless why maxima behaves like this. Can anyone help?
The variable you define is
sigma_z: 1000.0$ /*[N/mm²]*/
but then you call
simga_z*0.7;
Please, notice the difference between sigma_z and simga_z.

How to find nth derivative of a function using leibnitz rule in wxMaxima?

I know the pseudo code.
It goes something like this:
if f(x): g(x)*h(x) then u:g(x) and v:h(x)
for i:0 thru n do block
( binomial(n,i)*diff(u,x,i)*diff(v,x,n-i), i:i+1);
I'm not able to actually execute the code. I get some thing I don't need. Please
help me.
Thankyou
kill(all)$
y:x^4*log(x);
u:log(x);
v:x^4;
n:4;
lsum(binomial(n,i)*diff(u,x,n-i)*diff(v,x,i),i,[0,1,2,3,4]);

I can't run my code?

i made a script for garry's mode, using lua to code a script that allows me to when i bind a key, it will do a jump, then a 360 turn and shoot, but when i finished coding it, it won't let me run a test on it, why is this, and can you by chance tell me what i did wrong in the code. I am also 90% sure that the turn doesn't make a full 360, so if you could help me with that, i will be greatful. thanks.
Code:
function 360JumpShot()
timer.simple(.01,jump)
timer.simple(.02,turn)
timer.simple(.04,turn)
timer.simple(.06,turn)
timer.simple(.08,turn)
timer.simple(.10,turn)
timer.Simple(.12,Turn)
timer.Simple(.14,Turn)
timer.Simple(.16,Turn)
timer.Simple(.18,Turn)
timer.Simple(.20,Turn)
timer.Simple(.22,Turn)
timer.Simple(.24,Turn)
timer.Simple(.26,Turn)
timer.Simple(.28,Turn)
timer.Simple(.30,Turn)
timer.Simple(.32,Turn)
timer.Simple(.34,Turn)
timer.Simple(.36,Turn)
timer.Simple(.36,Turn)
timer.Simple(.40,Turn)
timer.Simple(.45,Turn)
timer.Simple(.50,Turn)
timer.Simple(.55,Turn)
timer.Simple(.60,Turn)
timer.Simple(.65,Turn)
timer.Simple(.70,Turn)
-- Get Noscoped
timer.simple(.7,function() RunConsoleCommand("+attack") end)
timer.simple(.72,function() RunConsoleCommand("-attack") end)
end
function Turn()
-- Turn(360)
LocalPlayer():SetEyeAngles(LocalPlayer():EyeAngles()-Angle(0,10,0))
end
function jump()
LocalPlayer():EyeAngles() LocalPlayer():SetEyeAngles(Angle(a.p-a.p-a.p, a.y-180, a.r))
end
-- Console Command
concommand.ADD("360Jump",360JumpShot)
alright, i got it to work.
Firstly, you cannot start your functions with digits so change
function 360JumpShot()
concommand.ADD("360Jump",360JumpShot)
to
function JumpShot()
concommand.Add("360Jump",JumpShot)
note that i also changed ADD to Add because LUA is case sensitive, considering that.. change
timer.simple(.01,jump)
timer.simple(.02,turn)
timer.simple(.04,turn)
timer.simple(.06,turn)
timer.simple(.08,turn)
timer.simple(.10,turn)
timer.simple(.7,function() RunConsoleCommand("+attack") end)
timer.simple(.72,function() RunConsoleCommand("-attack") end)
to
timer.Simple(.01,jump)
timer.Simple(.02,Turn)
timer.Simple(.04,Turn)
timer.Simple(.06,Turn)
timer.Simple(.08,Turn)
timer.Simple(.10,Turn)
timer.Simple(.7,function() RunConsoleCommand("+attack") end)
timer.Simple(.72,function() RunConsoleCommand("-attack") end)
after these changes your script works fine but you might want to find a way to move faster because your camera movement is very slow and is probably not exactly what you want.

Resources