What is Loop: Definition and 1000 Discussions

In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Various keywords are used to specify this statement: descendants of ALGOL use "for", while descendants of Fortran use "do". There are other possibilities, for example COBOL which uses "PERFORM VARYING".
A for-loop has two parts: a header specifying the iteration, and a body which is executed once per iteration. The header often declares an explicit loop counter or loop variable, which allows the body to know which iteration is being executed. For-loops are typically used when the number of iterations is known before entering the loop. For-loops can be thought of as shorthands for while-loops which increment and test a loop variable.
The name for-loop comes from the word for, which is used as the keyword in many programming languages to introduce a for-loop. The term in English dates to ALGOL 58 and was popularized in the influential later ALGOL 60; it is the direct translation of the earlier German für, used in Superplan (1949–1951) by Heinz Rutishauser, who also was involved in defining ALGOL 58 and ALGOL 60. The loop body is executed "for" the given values of the loop variable, though this is more explicit in the ALGOL version of the statement, in which a list of possible values and/or increments can be specified.
In FORTRAN and PL/I, the keyword DO is used for the same thing and it is called a do-loop; this is different from a do-while loop.

View More On Wikipedia.org
  1. cookiemnstr510510

    Square copper wire loop within a magnetic field

    Homework Statement In the figures below, a copper wire of circular cross section, A, has been bent into a square loop of side length, c, and arc welded at the seam for electrical continuity. Assume that the resulting square loop has a resistance, R, and a mass, M. The loop is originally held...
  2. S

    Lenz's law: Current induced in a split loop by a changing B-field

    Homework Statement We have a circular loop of wire, with AB is another wire which is also the diameter of the circular loop. The direction of magnetic field is perpendicular to the loop, into the plane of paper. The magnetic field strength is decreased at a constant rate, without changing the...
  3. cookiemnstr510510

    Forces of a straight wire on a semi-circular wire loop (Magnetism)

    Homework Statement An ideal, infinitely long straight wire carries a current I1 and is partially surrounded by a loop of current as shown below (image attached). The loop has length L, parallel to the infinitely long wire. The loop carries current I2. A) Calculate the magnitude and direction of...
  4. M

    Interpretation of a memristor's hysterisis loop

    Hi forums, Following is the hysteresis loop of a standard memristor: Please note that, the red one is for lowest frequency and black for highest frequency. From the graph, one can take the following observations: 1> As frequency increases, area of graph decreases 2> With increase in frequency...
  5. Ramtin123

    A Computing amplitude for divergent loop diagrams?

    I am trying to compute the cross-section for the diagram below with a divergent triangle loop: where ##X^0## and ##X^-## are some fermions with zero and negative charge respectively. I am interested in low energy limits, so you can consider W-propagator as ##\frac {i\eta_{\mu\nu}} {M_w^2}##...
  6. M

    Python Problem with appending a dataframe after a loop

    I am iterating over 2 variables below and after the calculation are done, i'd like to append the dataframe to add the rows after each iteration, but what is happening now is that the row is getting replaced instead of getting added. pre = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] post = [0, 1, 2, 3, 4...
  7. S

    Is Walter Lewins Loop Trick. Correct or False?

    Homework Statement I posted this in the advanced section, but glancing over the problems there I realized this probably belongs here.[/B] Hello everyone. I hope this is the right category. I am in desperate need of help. I have no High School Education. But a few weeks ago I participated in an...
  8. Beth N

    Circular motion: normal force on a loop

    Homework Statement A 180lb pilot flies a verticle loop with radius 2000 ft at 350 mi/h. With what force does the seat fress upward against him at the bottom of the loop? Problem 6.21 Homework Equations ##F=ma## ##F_c=\frac {mv^2} {r} ## The Attempt at a Solution There seems to be a...
  9. O

    E-field generated by constant current in a circular loop

    Homework Statement Discussions of the possibility of a tangential E-field external to a current-carrying conductor must include a voltage source and a return path. Here the problem is reduced to (we believe) the simplest possible geometry. Assume that a circular conducting loop has constant...
  10. L

    MATLAB Can I add a force stop condition in a loop

    i have keithley currnet source that i control with matlab, inside a loop, if i force stop the loop the device continue to output the last current. my question is can i add if condition that turn of the current source? for example if force stop fprintf(device, ':OUTP OFF') end
  11. pobro44

    Divergence of B, circular current loop

    Homework Statement [/B] ∇ * B = 0 and ∇ X B = Mu * J. This is proved to hold not only for infinite wires but for magnetostatics in general. Magnetostatics = steady current Closed wire loop with constant current is certainly a magnetostatics example. Magnetic field on z axis above loop around...
  12. K

    Induced Current in Stretched Square Loop: Flux Change and Direction?

    when a square loop is stretched to make a rectangular or circular loop(wire length remain same) in uniform magnetic field into the plane of paper what could be the direction of induced current. please share explanation as well
  13. E

    Python Convert a FOR loop to parallel processes

    Hi, I know that Python supports parallel programming. I think it can be used in my case but not sure how. Basically I have this for loop out = [] for value in vec: out.append(func(value)) where func is some function that takes value as an argument. The different values in vec are...
  14. G

    Hysteresis loop magnetization of Gadolinium

    hello i have a few questions regarding hysteresis loop in ferromagnets as showen here . i had an experiment in which i took a piece of gadolinium and cooled it down using liquid nitrogen , than i put it in an apparatus as showen here , so i induct an oscillating magnetic field on it , forcing...
  15. G

    Energy in a rotating square loop

    Homework Statement A square circuit of resistance R=20Ω and side ℓ = 0,2 m spins 100 times per second around an horizontal axis that splits it in two. There is an uniform magnetic field B=1T perpendicular to the position ocupied by the circuit at t=0s. Calculate (1) the magnetic flux, (2) the...
  16. person123

    B How do you calculate induced EMF in an open loop with changing magnetic field?

    Let's say you have an open loop (like a section of a circle) in a changing magnetic field. I think there would be an induced EMF, but no current. What I can't figure out, though, is how to calculate the induced EMF. Using Faraday's law doesn't seem to help, as there's no enclosed area.
  17. J

    Direction of induced current in the loop

    Homework Statement Homework EquationsThe Attempt at a Solution I am having a little doubt as to how to think of the moving electron as a current . I am considering the moving electron as a very tiny (infinitesimal ) current element . It is as if when the electron is at A , there is a very...
  18. kyphysics

    Windows 10 Update - Caused Loop (Need a Computer )

    I have an ASUS X540S (a cheap $199 priced) laptop and it asked me to do an update a few days ago. I agreed and left it running to go to dinner. When I came back, it was in some weird screen asking me to select a language. I chose English and the next thing I know it was in some sort of loop...
  19. F

    The case that has the highest torque on the loop

    Homework Statement Homework Equations T = IAB sin θ ; θ is the angle between B and I. T = μ × B The Attempt at a Solution A) T = IAB sin θ T = √2 a b I B (θ = 45°) B) T = 0 , because θ = 0 C) T = 0 , because θ =180° D) T = μ × B The direction of μ = -k , because the fingers points to the...
  20. CantorsLuck

    A Momentum Energy tensor and Wilson Loop in Yang-Mills Theory

    Hello Everyone. I Was Wondering how excatly the Gauge invariance of the trace of the Energy-momentum tensor in Yang-Mills theory connects with the trace of an Holonomy. To be precise in what I'm asking: The Yang-Mills Tensor is defined as: $$F_{\mu \nu} (x) = \partial_{\mu} B_{\nu}(x)-...
  21. G

    I Wire loop in a static homogeneous field question

    I already did a similar question here but got very little response so I will try to reformulate my question into a better one.So, the basic idea of the original question was whether a Faraday disc aka homopolar generator be made such as to have no sliding contacts and the load being attached to...
  22. M

    Radiation field of charge moving in a circular loop

    Homework Statement [/B] I need to calculate de radiation field produced by a charge moving in a circular loop of radius a, considering the motion is not relativistic and zone of radiation (far field) .Homework Equations The scalar potential is: $$ V=\int \dfrac{\rho(x')}{|x-x'|}d^3x'$$ The...
  23. J

    Using Kirchoff's Loop Rule to Determine Currents in a Circuit

    Homework Statement Homework Equations Kirchoff's Rule The sum of all V = 0 The Attempt at a Solution [/B] I think I'm having a problem determining the current at r_2 and R_3. I had originally thought the currents at both resistors would be I_3, writing E_2 — r_2 I_3 — R_3 I_3 — I_1 R_1 = 0...
  24. T

    Faraday's Law - loop turning in the Earth's B-field

    Homework Statement Homework Equations Faraday's Law, Ohm's Law, definition of current[/B]The Attempt at a Solution We were given this solution:[/B] The above solution is leaving out a lot of intermediary steps. I don't agree that "the axis of the coil is at 20°, not 70°, from the...
  25. P

    Circular motion - ball in a loop

    Homework Statement This question is referring to the classic ball in a loop question where it is dropped from a height and slides into a loop de loop. Derive an expression in terms of theta the velocity of the ball at the time it loses contact with the track. Theta is measured from the...
  26. K

    Determining the B-field in center of current carrying loop

    Homework Statement Determine the B-field inside the middle of a circular loop of current. Homework Equations Attempt at using Ampere's law: ##\oint \vec{B} \cdot d \vec{l} = \mu_0 i## The Attempt at a Solution ##\oint B \cdot R d \theta = \mu_0 i \Rightarrow BR(2 \pi) = \mu_0 i \Rightarrow B...
  27. S

    Force from a Current in an Infinite Wire on a Square Wire Loop Nearby

    Homework Statement Figure 6.47 shows a horizontal infinite straight wire with current I1 pointing into the page, passing a height z above a square horizontal loop with side length l and current I2. Two of the sides of the square are parallel to the wire. As with a circular ring, this square...
  28. J

    Potential difference between two points in a loop

    Homework Statement Homework EquationsThe Attempt at a Solution If we consider the bigger semicircular arc BD alone then potential difference between B and D will be 4BvR . If we consider smaller semicircular arc AC alone then potential difference between A and C will be 2BvR . If we...
  29. C

    Find the maximum amplitude of the induced EMF

    Homework Statement [/B] A radio transmitter radiates isotropically at the frequency of 90.8 MHz. The peak magnetic field at a receiver, 9km from the transmitter, is ##9x10^{-10}T##. Calculate the maximum amplitude of the induced emf in a 12 turn coil with area A = ##90cm^{2}## at the receiver...
  30. F

    Pipe Expansion Loops: Benefits, Features & Usage

    Pipe loops are used to accommodate thermal expansion. I have seen many types and lengths but here is one example: https://www.engineeringtoolbox.com/steel-pipe-expansion-loop-d_1069.html I am a little unclear on why they can work. With any thermal expansion the stresses on the elbow joints...
  31. C

    Understanding the Ideal Op-Amp Negative Feedback Loop

    Homework Statement Hi, Here is what I know about the Ideal Op-Amp. - The open loop voltage gain is infinite - The output voltage is given by the following $$v_o = A(v_+ - v_-)$$ - Only with a negative feedback loop is $$ v_+ = v_-$$ My query is with regards to the negative feedback loop...
  32. A

    I Cavitation in a closed loop pumping system

    Dears Kindly, I want to hear from you regarding this topic. The system is closed cooling system. I believe it is difficult to attribute the sound you hear from centrifugal pump to be a cavitation especially if the discharge pressure is normal. The last time we had a problem with this system...
  33. J

    What is the current induced in the loop when the area is π(b2 - a2)?

    Homework Statement Homework EquationsThe Attempt at a Solution The area of the loop is π(b2 - a2) Emf induced E = Rate of change of flux = πk(b2 - a2) Resistance of the wire R = 2πλ(a+b) Current in the loop = E/R = [k(b2 - a2)]/[2λ(a+b)] . This doesn't matches with the given answer .
  34. TheBigDig

    Time-dependent potential difference between two ends of a loop

    Homework Statement A straight copper wire that carries a sinusoidal current with an alternating frequency of 50 Hz and a maximum amplitude of 0.5 A passes through the centre of a circular ring of a second copper wire, with the two wires orientated perpendicularly to each other. The radius of...
  35. E

    Momentum and energy conservation in a vertical loop

    Homework Statement Two beads with masses of M and m are threaded on a vertical loop with radius of R. M is released without velocity from a height of 1.5R from the bottom of the loop. The collision between the beads is completely elastic. What is the smallest mass M that will make the second...
  36. M

    Mathematica Using While Loops in Mathematica for Iterative Computations

    Hi PF! I'm trying to compute $$\phi_n(x)=\pi x^2+\int_0^{\pi} 3(0.5 \sin (3x)-tx^2)\phi_{n-1}(t)\,dt$$ given ##\phi_0 = 0##. I'd like to iterate this computation until ##\sqrt{\int(\phi_{n+1}-\phi_n)^2}< 0.1##. I've never used the while loop in Mathematica, tried reading the documentation but...
  37. H

    Find the current induced in a wire loop by a nearby current

    Homework Statement Homework EquationsThe Attempt at a Solution When the circuit moves creates magnetic force that moves the some charges in the wire and that is a current. That is what i thought. F = Q.v B sin theta B = ( permeability Of vacuum* I)/(2pi.r) But how to find the I? Thank you...
  38. Mayan Fung

    I Flux pinning effect and hysteresis loop

    I am taking an experimental course which requires us to conduct experiments by ourselves. One of the tasks is to demonstrate the flux pinning effect of a type II superconductor YBCO by magnetic levitation. The professor asked me to discuss the effect by using the hysteresis loop (magnetization...
  39. Richie Smash

    Why does conducting liquid moving in a loop produce DC

    Hi suppose you have a conducting liquid in a strong magnetic field, and this is pumped in a continuous loop through two electrodes, why does this produce a D.C current? My thinking is a simple answer, and that is that the D.C current is produce because the fluid is moving in one direction...
  40. F

    Discharge in a DC RC circuit and Kirchhoff's Loop Rule

    Hi all, I think this issue periodically resurfaces in PF. I have found a similar discussion in this closed post and possibly others. I'm posting this because I'd like to check my understanding, if anyone is available to provide some furtherinsight. So I'm trying to gather a "overall"...
  41. A

    Field of a circular loop around its axis issue

    Good , i want to derive the formula for field of a circular loop around its axis but i was stucked with the following point: they consider dl perpendicular to r ! why is that?? many thanks in advance!
  42. D

    Why does entering '0' terminate do-while loop here?

    I am relatively new to programming and C++ and for the life of me I can't figure out why entering a '0' as input in the do-while loop here terminates the loop. // vector::push_back #include <iostream> #include <vector> int main () { std::vector<int> myvector; int myint; std::cout <<...
  43. T

    Pump ESP for infrastructure water network with loop

    Hello Everyone, I've been tasked with verifying the pump external static pressure for an infrastructure water supply network. The network is a series of loops as shown in the image attached . According to the calculation notes done by the designer, the design of the network was done in watercad...
  44. DeathbyGreen

    I Loop Integral Form: Finding a Workable Solution without Regularization

    Hi, I'm trying to calculate an integral which looks unfortunately divergent. The structure is similar to a loop integral but the appendix in the Peskin textbook didn't have a useable form. The integral form is (I did a u substitution to make it easier to look at) \int_x^{\infty}du...
  45. nothing909

    Expression for closed loop gain of differential amplifier

    Homework Statement The question is Derive an expression for the closed loop gain of the differential amplifier. I have solutions for these questions but the solution for this question is quite vague. Here is the solution: I understand part 1 and part 3, but part 2 I don't. So looking at...
  46. CDreyer23

    Rate of Change of Magnetic Field in Square wire loop

    Homework Statement The circuit shown is in a uniform magnetic field that is into the page. The total current in the circuit is 0.20 A, flowing counterclockwise. At what rate is the magnitude of the magnetic field changing? Is it increasing or decreasing? Square wire loop with base and height...
  47. M

    Speed at the top of the loop with energy loss from friction

    Homework Statement If the car is going 30 m/s half way up the loop and loses energy due to friction at a rate of 2.0J per meter of track, how fast will it be going at the top? (this is question related to the loop of roller coaster track, with radius 20m.) Homework Equations 1. Ki + Ui = Kf +...
  48. T

    Wire loop falling out of a magnetic field

    Homework Statement Here is a link to the problem: https://imgur.com/a/0T9sF I am having trouble finding the time it takes the loop to leave the field in part a. Homework Equations ## emf=-\frac{d \Phi}{dt} ## ## \Sigma F=ma=mg-BIl ## ## \frac{dv}{dt}-\gamma v=g ## where ##...
  49. astrocytosis

    Induced current in a loop of wire when straight wire is cut

    Homework Statement A square loop, side a, resistance R, lies a distance s from an infinite straight wire that carries current I (pointing to the right). Now someone cuts the wire, so I drops to zero. In what direction does the induced current in the square loop flow, and what total charge...
  50. C

    I Two Loop Beta Function for Strong Coupling in QCD

    A one loop expression for the strong coupling can be calculated with the result $$\alpha_s^{(1)}(\mu^2) = \frac{4\pi}{b_o \ln(\mu^2/\Lambda^2)}\,\,\,\,\,(1), $$see e.g in the first few pages of the attached file, where $$Q^2 \frac{\partial \alpha_s(Q^2)}{\partial Q^2} = \beta(\alpha_s) =...
Back
Top