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. G

    Making a Shortwave listening antenna

    Thanks to @berkeman for the ARRL book recommendation. While trawling through the theory, I’d like to build an antenna to help cement theory with practice. The receiver is an old valve/tube radio, covering the SW band from 6-18 MHz, or 49-16m. For simplicity, I thought a small, tuned loop...
  2. S

    I Shielded magnetic loop probe / antennas

    From a purely physics point of view, what would be the performance tradeoffs between the following types of shielded H-field pickups or antennas? Sources: https://owenduffy.net/blog/?p=18180 https://emcesd.com/tt120100.htm (A) (B)...
  3. skibidi

    Kirchhoff's law: Find the current I3 through the Amp meter

    I separated the circuit into parts- upper and lower For the upper loop I wrote: -14-2I1-3.4I3-I2 = 0 For the lower loop I wrote 16-2.9I2+3.4I3-5.4I2 = 0 I solved for I1 and I2 separately and plugged it into the junction rule and solved for I3. I may have got it wrong because of the...
  4. T

    I Circular loop in uniform magnetic field

    Consider a circular loop with uniform current flowing around it in a uniform magnetic field. Does it experience no translational force due to its symmetry
  5. Ramtin123

    A Renormalisation of the Fermionic triangle loop

    I am trying to renormalise the following loop diagram in the Standard Model: Using the Feynman rules, we can write the amplitude as follows: $$ \Gamma_f \sim - tr \int \frac{i}{\displaystyle{\not}\ell -m_f} \frac{i^2}{(\displaystyle{\not}\ell+ \displaystyle{\not}k -m_f)^2} \frac{d^4 \ell}{(2...
  6. C

    Loop the Loop Problem Solution | N > 0, Energy Conservation Method

    For this problem, The solution is, Does someone please know why ##N > 0##. I though at the min speed to still go around the loop, we could set ##N = 0## and ##mg## provides the centripetal force. Also, I am wondering how to do this problem with using energy conservation. My working is ## N +...
  7. A

    Induced voltage in loop with multiple switches

    If a current flowing within a loop is interrupted by a switch a spark occurs at some point which is a result of the built up potential across the opening switch contacts due to the stored energy in the magnetic field that was created by the flowing current. But what happens if I have a loop...
  8. F

    Determining Radius from Magnetic Field of a Single-Wire Loop

    So I thought I knew how to do this problem but I've run into some issues that make the algebra feel impossible and I am beginning to feel like I'm taking the wrong approach, I ended up rewriting it in a doc because I was concerned maybe my handwriting was the cause of my error so the work is...
  9. E

    Engineering Open Loop system with distance-velocity lag and single transfer lag

    Hi All, I have got as far as below, would anyone be able to go over this, I am a little confused with plotting this out onto a graph post equation Any help would be appreciated, I am hoping to get better understanding before I move onto the next question 4 = 10 (1-e^-t/5) t = -T in (output...
  10. D

    Calculate the induced EMF of a rotating loop

    there are a bunch of problems in this section that ask similar questions, but they ask the amplitude and this doesn't. this is an even problem so i do not have the answer, but my hunch is that it is not an amplitude question. i solved for the amplitude so i am guessing i got this one wrong...
  11. D

    Why does my game loop give me a blank screen?

    Hi everyone I've used a game loop to try make a textView alternate between two different strings every two seconds. When I run it, I just get a blank screen. The textView was originally set to show "Hello World!" but not even that shows. Does anyone know what's gone wrong? Thanks public...
  12. mastermechanic

    Electronics How to control a stepper motor in closed loop (PID) in arduino?

    Hello, What I have I have a NEMA17 stepper motor driven by a DRV8825 driver module, an arduino uno, a multiturn potentiometer. What I want to do I want to control the stepper motors in a PID closed loop. The motor shaft will be connected to the potentiometer and I will be sure that the motor...
  13. Hippo89

    Would a marble need the same speed as a car at the bottom of a vertical loop?

    I got the answer right, but it involved some guessing. So I’m here to make sure I got a conceptual understanding of this. Normal force is a contact force. If the car was not in contact with the loop (or barely in contact), the loop would exert no normal force on the car. So at the minimum...
  14. M

    Misc. Looking for help calculating heat transfer for PEX ground loop project

    Looking to build a suitable closed loop water (probably glycol mix) circulation system to prevent livestock water troughs from freezing. I assume that I need to calculate how much heat loss is predicted from the water tank in ambient air (varies, but assume worst case), then what length of heat...
  15. C

    Flux from magnet (Why is the Flux not zero through the loop?)

    For the problem attached, Why is the magnetic Flux not zero through the loop? Many thanks!
  16. C

    I In a closed loop system with a pump, how can we control the pressure?

    How can we control the pressure of the water inside a closed loop system (chiller system for example)? Let´s say, we have a pump curve and an system resistance curve that can be modified (through opening or closing some valves) In everywhere, what I see is that the intersection of the system...
  17. Leo Liu

    Mathematica [Mathematica] How to use for loop to process a list of data

    Hi. I am writing a program in Mathematica that reads a xsl file from excel, then processes it by solving an equation, and lastly turns the processed data into a list for exporting. Context: Finding the maximum speed of a model plane at different altitudes (density). Screenshots of the code and...
  18. Astronuc

    Couple's Epic 6,000-Mile Boating Journey Around America

    For those who appreciate boating. Manitowoc couple completes feat rarer than climbing Mount Everest — boating America's Great Loop, a one year and 6,000-mile journey https://www.yahoo.com/news/manitowoc-couple-completes-feat-rarer-130503326.html Great Lakes, Mississippi River, Gulf of Mexico...
  19. S

    Mathematica Loop with variable nesting depth and variable count at each level

    In Mathematica, how can we have "M" levels of nested loops, with each loop (level) going from 1 to Counts=##\{N_1, N_2, ... N_M\}## respectively, where the value of M and the elements of Counts are computed beforehand?
  20. V

    Analyzing while loop in matlab

    I am confused why this is the case, why would it output that number? When I go through the code, there is (x+1)-1 which does equal 1, then x = 2*x is 2? So why is the output not 2? How should I proceed in coming up with a solution? Does this have something to do with cancellation errors somewhere?
  21. Idontknowhatimdoing

    Normal force at the top of a vertical loop -- Circular Motion Dynamics

    From the equation for centripetal force, I can see that the centripetal force is proportional to v^2. Does this have something to do with why there is a normal force at the top? Does the velocity of the object require there to be a normal force? If so, why is that the case?
  22. guyvsdcsniper

    EMF when a loop is pulled away from a current-carrying wire

    Setting up the integral to find the flux that is giving me trouble. I know that I will have to break up this integral into 2 parts, the first part account for when the start of the loop is increasing in area, and another right when I pass the halfway mark of the loop and the area begins to...
  23. P

    How to model the behavior of a closed loop position system?

    Hello everyone, I would need help to model a motorized system controlled in a closed loop. It is a personal project. At first, I am looking to obtain the transfer function and simulate the system on computer. In a second step (not the aim of this thread), I would like to use this simulation to...
  24. TheHeraclitus

    I Carlo Rovelli, loop quantum gravity and point particles

    I am reading a popular-science book Reality Is Not What It Seems by Carlo Rovelli, one of the founders of loop quantum gravity. He writes: and and So basically, space (spacetime) is just another quantum field like all the others, and the quanta of this field is the nod. Nods have volume...
  25. H

    A Loop quantum gravity and General relativity

    Hi PFs, I am reading this paper written by carlo Rovelli: https://arxiv.org/abs/1010.1939 there are many things that i fail to understand, but i would like to begin with a simple thing. Rovelli write that: It is locally Lorentz invariant at each vertex, in the sense that the vertex amplitude...
  26. LCSphysicist

    EMF induced in a wire loop rotating in a magnetic field

    To solve this problem, we need to evaluate the following integral: $$\epsilon = \int_{P}^{C} (\vec v \times \vec B) \vec dl$$ The main problem is, in fact, how do we arrive at it! I can't see why a Electric field arises at the configuration here. The magnetic field of the rotating sphere is...
  27. A

    I Derivation of induced voltage in loop

    ##\phi_m = Blwcos\theta## voltage = ##\frac{-d\phi_m}{dt} = Blwsin\theta\frac{d\theta}{dt}## where l is the length of the loop and w is the width of the loop The top and bottom of the loop have magnetic forces perpendicular to the loop. My book says that means that there is no current through...
  28. L

    Force to apply to a loop moving away from a current-carrying wire

    What I have done: (1) ##\Phi(\vec{B})=\int_{S}\vec{B}\cdot d\vec{S}=-\frac{N\mu_0 il}{2\pi}\int_{s=h}^{s=h+l}\frac{ds}{s}=-\frac{\mu_0iNl}{2\pi}\ln(\frac{h+l}{h})## so ##\mathcal{E}=-\frac{d\phi(\vec{B})}{dt}=-\frac{\mu_0iNl^2v}{2\pi h(h+l)}## so...
  29. A

    Magnetic field with loop

    I am confused about this, do the black arrows represent the direction of magnetic force? The torque ##\tau = -IABsin\theta##, where I = current A is area of loop and B is magnetic field strength and I am a little confused how ##\theta## here is 45 degrees when the angle between the normal for...
  30. J

    Find largest potential energy difference between 2 loop orientations

    I thought the largest PE difference would be when the loop's area vector is in the same direction as the magnetic field, hence cos(0) =1, minus when the loop's area vector in perpendicular to the field, cos(pi/2) = 0. Just plug in the variables and you get 0.126 joules. Did I make a mistake?
  31. M

    Python Running a for loop in parallel via multiprocessing

    Hi PF! I'm wanting to run a function in parallel, which I've denoted integrate below, on line 33. from math import * from random import * import math, scipy.special import statistics import multiprocessing as mp # READ MATHEAMTICA FUNCTIONS with open("funcL.txt") as fileL: fL =...
  32. K

    I PID loop for a laser servo

    Hello! I am a bit confused about locking a laser to a stable cavity in practice. I understand there are 2 stages. In the first one you scan the laser frequency and the signal you see on an oscilloscope is made of peaks corresponding to when the laser is on resonance with the cavity. In this step...
  33. simphysics

    Single Loop Potential difference -- sign issue

    Hello everyone, I've been struggling with this problem for 1 hour so far. homework-and-exerciseselectric-cir
  34. A

    A Loop Quantum gravity or String theory?

    I understand that string theory has almost no testable predictions, however loop quantum gravity is an enticing candidate for only quantum gravity and it doesn't explain much of symmetry, constants, mixing angles etc in Standard model. There is obviously not enough evidence to create a full...
  35. theittsco

    A Renormalization with hard cutoff of a loop diagram with single vertex

    Trying to solve for the loop contribution when renormalizing a one loop ##\frac{\lambda}{4!}\phi^4## diagram with two external lines in ##d=4## dimensions. After writing down the Feynman rule I see that: $$\frac{(-i\lambda)}{2}\int d^4q \frac{i}{q^2-m_{\phi}^2+i\epsilon} $$ But I see no way to...
  36. downeast

    Pick the Best Compressed Air Inlet for Loop Pipeline

    Which compressed air inlet to a ring (loop) pipeline would likely be best in terms of least turbulance and best flow (avoiding dead head)? Given: 1) The inlet has to be in the corner of the rectangular loop. 2) Air consumption will be constant and evenly distributed throughout the loop. 3)...
  37. Hendra

    Ball rolling down a slope ending with a loop

    Hello everyone! I tried to solve this problem in a non-inertial system. Probably I should use the principle of conservation of mechanical energy in the following form $$mgH = \frac{3mgR}{2} + \frac{mV^2}{2}.$$ So the only thing to do is to compute $V^2$. I tried to find this value using the...
  38. ergospherical

    Justifying the peak closed loop gain of an op-amp circuit

    I'm just looking at a Bode plot of log(gain) vs log(frequency) for a an amplifier circuit. I'm trying to figure out whether I'm expecting to see a resonance in the gain at the frequency where I measured one. How could I, in principle, work out theoretically where the peak gain should occur - is...
  39. shivajikobardan

    Nested for loop in python, understanding with dry run?

    Here is the code that I am talking about-: n=int(input("Enter a number")) for num in range(2,n+1): for i in range(2,num): if(num%i==0): break else: print(num,end="") If I give n=5 output should be 2,3,5. Here is my dry run. Everything is fine except for 2...
  40. shivajikobardan

    MHB How does nested for loop works, can you explain with dry run?

    Here is the code that I am talking about-: n=int(input("Enter a number")) for num in range(2,n+1): for i in range(2,num): if(num%i==0): break else: print(num,end="") If I give n=5 output should be 2,3,5. Here is my dry run. Everything is fine except for 2...
  41. shivajikobardan

    Pynative while loop tutorial -- confused

    Summary:: confused in program. Write a while loop to display each character from a string and if a character is a space, then don’t display it and move to the next character. Use the if condition with the continue statement to jump to the next iteration. If the current character is space...
  42. Boltzman Oscillation

    Help finding the magnetic field of a current loop

    Hi all, my work is shown on the attached image. The boxed equation is what I get to but I do not understand how to go from there to what the book has. I am guessing that the problem arises when trying to solve the cross product. I understand that I will need to find the value of the sine of the...
  43. anubhavsingh

    CMRR in open loop and closed loop configuration of opamp

    For an opamp in open look configuration, Here Ad should be equal to open loop gain of opamp and Now consider the closed loop config of opamp (negative feedback used): However, Ad is closed loop gain here (according to Sedra Smith) and In terms of open loop gain, A is open loop gain...
  44. M

    Mathematica Saving an image in a for loop with an updated name

    Hello all! I am trying to export image0, image1, image2, etc in a for loop. What I have is For[i = 0, i < 4, i++, "image" <> ToString[i] = Rasterize[plfunc3dANGside2[6, 2, 115, 0.1*i], Background -> None, ImageResolution -> 1000]; Export["/home/josh/ISS_drops/vibrations/" <> "image" <>...
  45. AfonsoDeAlbuquerque

    A Triangulating Hamiltonian Constraint in LQG

    Im trying to obtain regularized (and triangulated) version of Hamiltonian constraint in the LQG. However, one step remains unclear to me. I am starting with the Euclidean Hamiltonian:$$H_E=\frac{2}{\kappa} \int_\Sigma d^3 x N(x)\epsilon^{abc} \text{Tr}(F_{ab},\{A_c,V\}) $$ Now i have to...
  46. T

    Dynamics of Four Bar Link using Hamilton's Principle with Loop Closure

    Summary:: Can someone point me to an example solution? Hello The attached figure is a four bar link. Each of the four bars has geometry, mass, moment of inertia, etc. A torque motor drives the first link. I am looking for an example (a simple solution so I can ground my self before...
  47. P

    Engineering Analyzing the output impedance and open loop gain of a IC-741 Op-Amp

    Here is the internal circuit of the 741 Op-Amp - Looking at the output stage, the output impedance seems to be the series combination of ##25 \Omega## and ##50 \Omega##, that is ##75 \Omega##. Is this a qualitative explanation enough to justify the output impedance, or am I wrong somewhere and...
  48. Anmoldeep

    I Work Done in Changing Shape of Current Carrying Loop

    How would you go about calculating the work done in morphing a square current-carrying loop into a circular current-carrying loop, without change in length while maintaining the same angular orientation with an external magnetic field. My book suggests defining P(potential energy) = M.B (dot...
  49. Rubberduck2005

    Centripetal Motion problem -- A bead sliding around a horizontal loop

    To be honest I am a bit clueless first with how to interrupt this question I think the bead is going around a wall type thing where there is friction both in the up and X direction. Some hint to get some ideas running would be great
Back
Top