Loop Definition and 41 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. M

    Showing that this identity involving the Gamma function is true

    My attempt at this: From the general result $$\int \frac{d^Dl}{(2\pi)^D} \frac{1}{(l^2+m^2)^n} = \frac{im^{D-2n}}{(4\pi)^{D/2}} \frac{\Gamma(n-D/2)}{\Gamma(n)},$$ we get by setting ##D=4##, ##n=1##, ##m^2=-\sigma^2## $$-\frac{\lambda^4}{M^4}U_S \int\frac{d^4k}{(2\pi)^4} \frac{1}{k^2-\sigma^2} =...
  2. G

    How to get the magnetic moment for this loop?

    About this figure, the current in the opposite wires are parallel (and not anti-parallel). So, for instance for the first option the torque is zero; but I wanted to know what is the magnetic moment of this loop. Since I rely only on formula I've have no idea how to compute for this one.
  3. Alefan_

    Average current around a magnetic loop that changes its shape

    To find out what the induced loop current was i used the formula: V=R×I To find out what the value of V was i used the formula that links electromotive force (fem) to angular speed: Fem=ω×B×A The only thing that's missing is the loops area but considering that it's a semicircle and that the...
  4. J

    Speed at the top of an elliptical roller coaster loop

    Homework Statement This isn't really a homework but a project I'm doing that's due soon. In our multivariable calculus class, we're creating a 3D roller coaster, and I need to explain the physics behind the roller coasters. For a roller coaster loop, if it were perfectly circular, we would...
  5. 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...
  6. 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...
  7. 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 +...
  8. J

    I How to calculate the area under a curve

    I was doing some integral exercises for getting area under the function. I was doing only more simple stuff, like functions that don't go over the same "x area" multiple times, like a quadratic function. My question is how to calculate area of a loop in an equation x^3+y^3-3axy=0 if let's say...
  9. C

    Critical Velocity in a roller coaster cart

    1. The problem statement, all variables, and given/known data I was just wondering if a roller coaster can still pass through a loop with less than critical velocity/energy (Also if I'm assuming critical energy correctly). The loop can be of any size yet it must not exceed 5.7g at the entry...
  10. dykuma

    I Conceptual question about warping spacetime

    First of all, I would like to admit that my understanding of general relativity is limited, though this will hopefully be remedied this summer when I take a GR class. I think we have all seen a sci-fi movie where the characters are stuck in a space where they are trapped in a sort of "warp...
  11. I

    Magnetic Flux Through a Square Loop

    Homework Statement A loop of wire in the form of a square 1.50 m on each side, its plane makes an angle of 40.0° with a uniform magnetic field of 0.95 T. What is the magnetic flux through the loop? Homework Equations Φ = BAcosθ A = s^2 The Attempt at a Solution I found the area of the square...
  12. D

    Calculating load factor for airplane

    Hello! When calculating the load factor in a loop the formula is n=V^2/(g*R)+cos(teta) during pull-up of a loop and another formula is n=1/cos(phi) during a level-flight banked turn. How does one combine these to calculate the load factor during a twisted loop?
  13. mamadou

    What is the minimum height?

    Homework Statement An empty ball , of mass m moment of inertia I = (2m.r²)/3, is rolling across the path shown below : there is friction fr from A to C . r is the radius of the ball , and R is the radius of the circular part within the path . what would be the minimal height h , so...
  14. Kanashii

    Finding the second derivative using central difference formula

    Homework Statement Develop aprogram that will determine the second derivative of pi(16 x^2 - y^4) at y=2 with step sizes of 0.1, 0.01, 0.001…. until the absolute error (numerical-analytical) converges to 0.00001. Use the 2nd order Central Difference Formula. User Input: y, tolerance Output: h...
  15. moenste

    Energy dissipated in the loop during mag. field change

    Homework Statement A closed wire loop in the form of a square of side 4.0 cm is mounted with its plane horizontal. The loop has a resistance of 2.0 * 10-3 Ω, and negligible self inductance. The loop is situated in a magnetic field of strength 0.70 T directed vertically downwards. When the field...
  16. L

    Roller-coaster problem

    In an amusement park, the new roller-coaster ride The Loopy Looper is com- posed of a number of full loops, where the car goes round upside down. The car is attached to the track, but there are no seat belts. Consider one such loop, which can be taken as a circle with radius r. The mass of the...
  17. moenste

    Current induced in the loop

    Homework Statement A closed wire loop in the form of a square of side 4 cm is placed with its plane perpendicular to a uniform magnetic field, which is increasing at the rate of 0.3 T s-1. The loop has negligible inductance, and a resistance of 2 * 10-3 Ω. Calculate the current induced in the...
  18. JustinT

    A different type of roller coaster loop problem

    Homework Statement A roller coaster at the nearby amusement park Physics Hill, has a large circular loop where cars travel at the top of the loop at 25.0 m/s causing the riders to enjoy an acceleration of 3g. Assuming the height of this loop is the same as the diameter, how high is the loop...
  19. moenste

    The balance reading when direction of mag. field changes

    Homework Statement The diagram shows a rigid conducting wire loop connected to a 6.0 V battery through a 6.0 V, 3.0 W lamp. The circuit is standing on a top-pan balance. A uniform horizontal magnetic field of strength 50 mT acts at right angles to the straight top part of the conducting wire in...
  20. M

    Engineering Circuits with Resistors

    Homework Statement https://s10.postimg.org/lb6n94ua1/20161007_190700.jpg Homework Equations V=IR The Attempt at a Solution So far I haven't had any problems finding the Req. However, I am having trouble with the VIR chart. Can anyone confirm whether or not I did it correctly. My thought...
  21. M

    Mathematica "Do" loop with "If" conditional

    Hi, I have a function defined by: F[x_,y_,z_]:=3 x+y-2Y[z] where Y[z_]:=3/z I'd like to run Do loop to calculate the value of this function for specific regions of x,y,z. I can use: Do[F[x,y,z],{x,1,2,1},{y,-2,-1,1},{z,3,5,1}], But I have two questions here: First: How to save the output...
  22. S

    B Using center of mass for loop de loop

    A quick question, I remember my professor said to use the center of mass for solving the classic loop de loop problem. For example, he wanted us to use the distance from the surface of the loop to the center of the object (instead of just from the loop to the surface of the block) for the height...
  23. S

    Magnetic field change for induced current

    Homework Statement A uniform magnetic field is perpendicular to the plane of a circular loop of diameter 10 cm formed from wire of diameter 2.5 mm and resistivity 8.5×10-8 Ω·m. At what rate must the magnitude of the magnetic field change to induce a 10 A current in the loop? Homework Equations...
  24. S

    Magnetic field strength for circular loop

    When deriving the magnetic field strength due to a circular loop at some distance away from it's center (using Biot-Savart's law), why is the angle between ds and r 90 degrees? This is a youtube video with the derivation, see 5:55
  25. S

    Biot-Savart's Law for cylindrical conductor

    Homework Statement The figure shows a cross section across a diameter of a long cylindrical conductor of radius a = 2.92 cm carrying uniform current 151 A. What is the magnitude of the current's magnetic field at the center of the conductor? Homework Equations Biot-Savart's Law The Attempt...
  26. A

    EMF about a loop moving toward a wire with current

    Homework Statement A picture of a related problem is attached below. My problem is the same, except that v is toward the wire, not away from it. I, r, v, b and a are given. "Find the emf about the loop without assuming that B changes at any point" My problem is that this question isn't...
  27. M

    Help with magnetic induction and finding induced current

    Homework Statement I have attached a picture that details the problem. This is my practice test and I have no clue what I am doing wrong. Essentially a loop of wire is moving in constant velocity into a magnetic field. The magnetic field lines are pointing into the page. The problem is...
  28. H

    Calculate the EMF induced in the square?

    Homework Statement A square of wire with side length 1.4 m rotates about an axis through one corner that is perpendicular to the plane of the square with an angular speed of 3 rev/s. There is a uniform magnetic field of 1.2 T perpendicular to the square. Calculate the EMF induced in the...
  29. E

    B-field generated by inducting loop of shrinking size (NEED SOMEONE TO CHECK ANSWERS)

    Homework Statement A little stuck on the second question it basically boils down to not quite understanding the question. Was hoping someone here could push me in the right direction. The Question is two part, already completed the first half but wouldn't mind if someone looked over it while...
  30. komarxian

    Rollercoasters and Loops and Normal Forces

    Homework Statement <I will attach a diagram below> In terms of m, g and r. FInd the normal force at the top of the loop. Homework Equations ∑F = Fc = FN+Fg ∴ Fc=FN+Fg ∴FN = Fc - Fg ∴ N=mV2/r - mg The Attempt at a Solution Fc=mV2/r - mg and V2=ra and a=g ∴C=mrg/r ∴C = mg ∴mg-mg=N ∴ N=0 N. BUT...
  31. I

    Loop-de-Loop with function of angle

    Homework Statement Task: [/B] On a friction free loop de loop, a object (m=600kg with passengers) moves with a velocity of vu = 120km/h at the lowest point of the loop. The loop has a radius of r=15m. The position of the object is given with the angle α. Derive the formula for the velocity...
  32. O

    Task: Function for the acceleration throughout a loop?

    So, this seemed really fun to me until I got stuck. THE TASK is about an object with mass m, moving in a basic (2D) coordinate system. It is attached to origo (0, 0) by a "rope" with constant length r=5. In position P0(-5, 0) it has the velocity v0=[0, -10]. Hence, the object moves around origo...
  33. Jairo Rodriguez

    Dropping a mass on a slope, entering a loop and stopping.

    Hello, today our teacher told us that on tomorrow's test there is going to be a problem where you drop a mass on a slope which connects into a loop. The point of the problem is to calculate exactly how tall the slope must be for the mass to complete exactly one course through the loop...
  34. Y

    Magnetic field due to a loop within the area of the loop

    Homework Statement This is a question me and my friend were wondering about. How can one calculate the magnetic field due to a current carrying loop at a point in the area enclosed by the loop. For example, at point P as shown in the attached figure. Homework Equations $$B =...
  35. A

    Comp Sci Python: How to show entered input results when entering a 0

    Homework Statement So, I have a program, which I am finishing but I apparently ran into a problem. In the program I have to make that whenever I enter a 0 in the input, the program will stop and print the results. Here's the program before I continue saying anything else: The Attempt at a...
  36. A

    Asking a user for a correct input until they give a correct response

    Homework Statement I need a program (in PYTHON), which would ask a user his name and grade, then print them both. 1) If the name has a number it, the program has to ask the same question again until the name is entered correctly 2) The same with the grade. If it's higher than 10, the program...
  37. A

    Transformer efficiency

    Homework Statement Transformer efficiency loss Homework Equations Larger transformers are more efficient than smaller The Attempt at a Solution I understand the basics of energy loss through heat etc but i don't understand why it would be different for the sizes of transformers. Is it to do...
  38. T

    Biot-Savart non-textbook Equation -- B at point above a loop but off-axis

    I read everywhere about the formulas for calculating B at a point from a length of straight wire, or at a point from the centre of a closed loop. But what about at a point over a closed loop that wasn't the centre? Is there a simple calculation for that? Thanks
  39. Hijaz Aslam

    Force on a circular loop due to hypothetical magnetic field.

    Homework Statement A hypothetical magnetic field existing in a region is given by ##\vec{B}=B_o\vec{e}_r##, where ##\vec{e}_r## denotes the unit vector along the radial direction. A circular loop of radius a, carrying a current ##i##, is placed with its plane parallel to the X-Y plane and the...
  40. G

    Difference between a spinning sphere and rolling one

    Consider this: We have a sphere rolling down a slant, released from some height h with null velocity. At the end of the slant its potential energy will have been fully converted to kinetic energy, part translational and part rotational. Now consider this: at the end of the slant the ball enters...
  41. E

    Car going around loop

    1. So the loop is known to be 12m in diameter (6m radius). Assume the car weighs 1250kg - how fast must the car go to clear the loop, and what will be its max G-forces endured? This was the question, which I have broken into 3 sections: a) Velocity at top of loop (done) b) Velocity at start of...
Top