Welcome to ZyberPH. Be one of us! Read first our VIP RULES. For more info and guide you. Read our FAQ

Python Programming SERIES: #5 (for loop)

Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Python, Ruby, WML, SQL, XML, and other programming languages.
Post Reply
User avatar
cavin12400
Developer
Developer
Posts: 25
Joined: Wed Apr 06, 2016 12:10 pm
Location: Y̢ǫu͟ ͞c̶a̴n'҉t trac̨k ̡m̡e
Contact:

Python Programming SERIES: #5 (for loop)

Post by cavin12400 »

Hello Zyber! I wont take this long. Medyo busy.

START: For Loop

So andito nanaman tayo sa python tutorial. If nagskip kayo dito sa tutorial number 5 please lang e close niyo na. balik kayo sa tut number 1.

~> So what is loop? Loop po, a structure, series, or process the end of which is connected to the beginning.
~> dimo gets ano? Loop po pabalik balik. So meaning sa tut na ito tuturuan ko kayo kung papano magloop sa iyong program.

~> First example natin is magloop tayo ng string na Hello World ng sampong beses.
~> Ganito ang syntax nya:
for variable in range(starting,end):
statement
~> Always tandaan na ang default na starting is zero YES! ZERO bes.
~> ganyan lang ka simple. So ano ang nasa luob ng starting at end? syempre. mag start sa starting at mag end sa end. pero kapag hindi ka nagspecify ng iyong starting, eto mangyayari: for variable in range(count): . magiging ganyan ang syntax nya. remember that starting,end and count are all numbers or can be variable as long as ang variable ay integer type. so para ma intindihan niyo. eto example:

~>
for i in range(10):
print("Hello World)"
~> in this case count ang ginamit natin.
Image
~> At ang result ay:
Image

~> So what if gamitin natin si starting at end?
for myVariable in range(1,10):
print(myVariable)
~> Sa sinabi ko kanina, ang default na starting point is zero so ganito ang mangyayari. dapat hanggang 9 nalang sya:
Image

~> So mga besh! dito nayong point na mag experiment kana! Goodluck sa pag gamit ng for loop!
Mwaaah! :he: :he:

Leave a Donation bes. kapagod. Next tutorial: Python Programming SERIES: #6 (While loop)
f**k!
Post Reply

Return to “Programming & Web Design”