Closed Nahihirapan ako maunawaan yung Nested Looping

Status
Not open for further replies.

Arlertz

Eternal Poster
Hi guys! Inaaral ko po yung Python. Actually, sinubukan ko aralin yung JavaScript at C# noon pero huminto din ako dahil nahirapan ako maunawaan talaga yung nested looping. Tapos nahinto na naman ako. May work ako sa SEO company, pero yung ginagawa ko ay pakiramdam ko repeated tasks lang. Cool naman boss ko at mabait kaya relax ang work. Pero gusto ko talaga matutuhan yung programming kasi gusto ko makagawa ng program o web apps. Kaya sinimulan ko aralin ngayon yung Python kasi sabi madali daw siya sa lahat. Naiintindihan ko naman yung variables, if/else, conditional operator, at yung for and while loops kung isang loop lang. I mean

Python:
numbers = [8, 3, 5, 12, 21]

count = 0

for number in numbers:

    if number % 2 == 0:

        print(number)

        count += 1

if count > 1:

    print(f"You have {count} even numbers")

else:

    print(f"You have {count} even number")

Pag mga ganyang simpleng code lang naiintindihan ko yung looping. Pero kapag nested loops na, hirap na ko. Kapag nakita ko yung solution, parang naiintindihan ko naman yung nangyayari. Pero kapag ako na ang gagawa ng program, waley na finish na 😅 :sleep:

Ayoko aralin yung mga susunod na parts ng tutorial kasi alam kong mahihirapan din ako don kung hindi ko mauunawaan talaga yung nested looping.🤪
 
Did you know?

Web hosting is a service that allows organizations and individuals to post a website or web page onto the Internet. A web host, or web hosting service provider, is a business that provides the technologies and services needed for a website or webpage to be viewed on the Internet. Websites are hosted, or stored, on special computers called servers.

When Internet users want to view your website, all they need to do is type your website address or domain into their browser. Their computer will then connect to your server, and your webpages will be delivered to them through the browser.

When it comes to web hosting companies based on the number of hosted websites, GoDaddy has established itself as a clear market dominator. According to HostAdvice, GoDaddy has covered over 19% of the market, leaving a not-so-significant market share to other hosting providers such as Google Cloud Platform, 1&1, Amazon Web Services, and Cloudflare.

According to Builtwith, GoDaddy has also managed to become a world dominator when it comes to providing VPS web hosting. GoDaddy’s market share in this segment counts for over 23%, whereas its closest competitors, such as DreamHost and Digital Ocean, cover 1.46% and 1.23% of the market share, respectively.
always keep in mind. Outside loop will not continue if inside loop has not met its condition yet.

example outside loop 3 repitions, inside loop has 2 repitions

1. outside, inside inside
2. outside, inside, inside
3. outside, inside inside

end of loop, assuming inside loop statements met conditions or ends in a never ending cycle
 
nested loop is a looping consists of 2 or more loops. it can be a mix of different loops like while, for and foreach. Child loops cannot be executed once the statement from the mother loop is not met. All of the given number of loops given to child loop is executed before the next loop from the mother loop is executed.
 
na ka pag c++ ka ba? atleast nahasa yung understanding mo looping { } each loop most may ganito, start end.. or gamit ka ng ide atleast guide.
 
Hi guys! Inaaral ko po yung Python. Actually, sinubukan ko aralin yung JavaScript at C# noon pero huminto din ako dahil nahirapan ako maunawaan talaga yung nested looping. Tapos nahinto na naman ako. May work ako sa SEO company, pero yung ginagawa ko ay pakiramdam ko repeated tasks lang. Cool naman boss ko at mabait kaya relax ang work. Pero gusto ko talaga matutuhan yung programming kasi gusto ko makagawa ng program o web apps. Kaya sinimulan ko aralin ngayon yung Python kasi sabi madali daw siya sa lahat. Naiintindihan ko naman yung variables, if/else, conditional operator, at yung for and while loops kung isang loop lang. I mean

Python:
numbers = [8, 3, 5, 12, 21]

count = 0

for number in numbers:

    if number % 2 == 0:

        print(number)

        count += 1

if count > 1:

    print(f"You have {count} even numbers")

else:

    print(f"You have {count} even number")

Pag mga ganyang simpleng code lang naiintindihan ko yung looping. Pero kapag nested loops na, hirap na ko. Kapag nakita ko yung solution, parang naiintindihan ko naman yung nangyayari. Pero kapag ako na ang gagawa ng program, waley na finish na 😅 :sleep:

Ayoko aralin yung mga susunod na parts ng tutorial kasi alam kong mahihirapan din ako don kung hindi ko mauunawaan talaga yung nested looping.🤪

AVOID NESTED LOOPS IF POSSIBLE.

There will be cases where you might really need it. If you think you need one, I suggest to think again. Search online for possible alternatives.

Prefer declarative programming or properly decomposed pure functions.

The simple reason why you want to avoid nested loops is they can get confusing for other devs to read. If you think it's difficult for you to read your code, it's probably more difficult to read your work too.
 
Also I don't think Python is the easiest programming language to use. If you are used to C-style programming, Python may look foreign to you. Same as Ruby.

If you are Java dev, JavaScript might be an abomimation to you. Nothing is easy. My father used to tell me, "Madali kapag alam mo. Mahirap kapag hindi mo alam".
 
AVOID NESTED LOOPS IF POSSIBLE.

There will be cases where you might really need it. If you think you need one, I suggest to think again. Search online for possible alternatives.

Prefer declarative programming or properly decomposed pure functions.

The simple reason why you want to avoid nested loops is they can get confusing for other devs to read. If you think it's difficult for you to read your code, it's probably more difficult to read your work too.
Agree use functions() para neat yung coding Lalo pag sa field ka team kau sa project. Magpupull ka sa repository nyo sasalahin pa yan, Kala mo pinakamahirap mag code, mas madugo yung documentation.
 
Not really a fan of imperative style programming; loops within loops, nested if-else and prone to side effects. There's always a first time sa lahat ng bagay, kung ngayon pa lang aatras ka na dahil nahihirapan ka na sa fundamentals then programming is not for you bro. Proceed ka sa next tutorial mo, then you will know na may tinatawag tayong HIGHER ORDER FUNCTIONS ex. map, filter, reduce..etc. Sigurado ako magugustuhan mo yun kaysa sa loop, at maiintindihan mo kung bakit may Loop sa programming.
 
I think it will really help if you think nested looping as comparable to that of order of operations in basic arithmetic. By default, basic order of operations is Multiplication->Division->Addition->Subtraction. Say, you have this very simple equation:

Code:
x=1+4-5%4*2

If you are not going to consider the order of operations but rather compute in a left to right manner, what will you get?

In nested loops, innermost loop is computed first then the next until you hit the outermost loop. And for each iterations, the results are stored/manipulated along the way.
 
Basta practice lng dahil beneficiary yan for all languages ma encountered mo. Specially yung OOP nahirapan ako sa inheritance
 
Status
Not open for further replies.

About this Thread

  • 13
    Replies
  • 820
    Views
  • 9
    Participants
Last reply from:
Migfus

Trending Content

Online now

Members online
1,312
Guests online
19,186
Total visitors
20,498

Forum statistics

Threads
2,037,235
Posts
27,593,276
Members
1,591,224
Latest member
Japh
Back
Top