Getting to know Thonny

Hey guys!
In my first blog I said that we are using another program then Python for the programming. In this class today I found out that it was Thonny, so now I am using that and it’s looks easier than the Python. I started to use it with thinking what I wanted to achieve. So, I decided to want my variable m to count to ten and when it reaches ten and must say that it reached ten. (sorry I a made my script in Dutch). But after a lot of trying it worked out. To achieve this you first need to produce a variable with a name (in my case m) that gets a value (in my case 1). After that you need to produce a loop that checks every time if the variable m is still belowe ten (m<10). And you need to tell Thonny that he has to count plus one if it is the case (m=m+1). And of course you need Thonny to display the value of m to control it a little bit (print(m)). Okay that was the second step to achieve this. Now we are at the third and final step: we need to tell Thonny that if the value of m is 10 or higher (with my thing was equal to ten also enough, but ten or higher is safe for the case that you use m+2,3,4 or 5 instead of one) he needs to say: we achieved ten. And that is the last two lines of my script (see picture below). Now this has worked out, I think my first script worked.

Okay, sadly I found out after I wrote my blog that there was an assignment that we needed to make.

So, now I am going to explain what I did during the assignment. This was the assignment that we needed to make:

So, now I am going to explain what I did during the assignment. This was the assignment that we needed to make:

And this is the script that I used to achieve this and the result that it gave:

If you want to do this with other numbers it is just possible to change the value of a and b. To open my blog, click on the picture of my script.
In the variable menu at the upper left you can see the values of the variables that I made. I think it works very practical to open this window, because it shows you exactly what Thonny is doing with your numbers. You can open it with view –> variable.

You can see different value of f in my variable menu and they all have something to do with the integer. With the “//” (f1) is rounding it downwards. The “round” function rounds it in my case to the closest number with 0 decimals behind the comma. If you put round(f,2) you get a number with 2 decimals.

Advertenties

Plaats een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s

Maak je eigen website aan bij WordPress.com
Aan de slag
%d bloggers liken dit: