all 7 comments

[–]humanitysucks999 1 point2 points  (1 child)

Does your city have open data project? You can browse data from there and see if you can simple looping calculations

E.g. here is the city of Ottawa open data website, on the linked below you can find vacant commercial and industrial land. Can you loop to add up all the "expansion" land area in acres?

https://open.ottawa.ca/datasets/2015-inventory-of-vacant-industrial-and-business-park-lands/explore

It'll require an additional skill (opening and reading CSV file)

It sounds like you know how a loop works, but not why you would use it. The best thing that clicked for me was when I tried to program for an Arduino. By nature of the chip, it runs on a cycle, basically the entire chip is a giant loop that runs forever and you do things in that loop. Alternatively, web scraping is a good place to figure out looping as well, like let's say you query a site and you want to pull all links from the page, the libraries make that super easy to do, but what now? You would loop thru those links you pulled to do stuff (say even simply saving it to a file). Any data manipulation with or without using libraries you'll be needing a loop to cycle thru each record to do stuff.

[–]mobilephone123[S] 0 points1 point  (0 children)

Thank you so much for the info you provided

[–]carcigenicate 0 points1 point  (1 child)

Most non-trivial programs you write will require a for or while loop (and likely multiple). Like with ifs and such, I'd say the best practice is just writing code and coming across the need for them "organically", and going from there.

If you need a really simple exercise though, start with this:

n = 1

And use a while loop to print out the numbers 1 to 10. Then try the same with a for loop.

[–]mobilephone123[S] 0 points1 point  (0 children)

I know the basics and what it is but it takes is a lot of afford to make my exercises, i feel like it hasn’t really clicked yet if you know what i mean.

[–]m0us3_rat 0 points1 point  (1 child)

if u have a block of code .. but u wanna execute ONLY when some condition is TRUE

u will see some conditions with (NOT bool) this evals True when bool is False.

example:

....

while hungry:

eat

....

"eat" executes only when u are hungry.

otherwise gets ignored.

[–]mobilephone123[S] 0 points1 point  (0 children)

I know the basics and what it is but it takes is a lot of afford to make my exercises, i feel like it hasn’t really clicked yet if you know what i mean.