Python for Kids: The New Step-by-Step Parent-Friendly Programming Guide With Detailed Installation Instructions. To Stimulate Your Kid With Awesome Games, Activities And Coding Projects by Deep Raymond

Python for Kids: The New Step-by-Step Parent-Friendly Programming Guide With Detailed Installation Instructions. To Stimulate Your Kid With Awesome Games, Activities And Coding Projects by Deep Raymond

Author:Deep, Raymond [Deep, Raymond]
Language: eng
Format: epub
Published: 2020-06-23T16:00:00+00:00


Chapter 9 For Loop

We will discuss the for loop. Just like a while loop, the for loop also repeatedly executes a set of code while the condition holds true. Once the condition becomes false, it will come out of the loop. Some basic requirements of a for loop are:

It must refer to a list or a range

It ends with a (:) colon

The code which has to be executed should be indented by one tab space

Example3:

# First Example

for letter in 'Python':

print 'Current Letter :', letter

Output:

Current Letter : P

Current Letter : y

Current Letter : t

Current Letter : h

Current Letter : o

Current Letter : n

# Second Example

fruits = ['apple', 'banana','mango'];

for fruit in fruits:

print 'Current fruit :', fruit

print "Good bye!"

Output:

Current fruit : apple

Current fruit : banana

Current fruit : mango

Good bye!

# Measure some strings

words = ['cat', 'apple', 'defenestrate']

for w in words:

print w, len(w)

Output:

cat 3

window 6

defenestrate 12



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Building Machine Learning Systems with Python by Richert Willi Coelho Luis Pedro(2058)
Hands-On Python Deep Learning for the Web by Anubhav Singh(1938)
Mastering OpenCV 4 with Python by Fernández Villán Alberto;(1781)
Building Serverless Python Web Services with Zappa by Abdulwahid Abdulhaque Barguzar(1709)
Mastering Python Data Visualization by Kirthi Raman(1646)
PYTHON PROGRAMMING ADVANCED: The Guide for Data Analysis and Data Science. Discover Machine Learning With the Optimum Recipes for Mastering Python and ... (Crash Course Tips and Tricks Book 3) by ERIC MATTHEWS & LEWIS TAYLOR(1631)
Python for Finance Cookbook by Eryk Lewinson(1618)
Python for Finance: Analyze Big Financial Data by Yves Hilpisch(1602)
Supervised Machine Learning with Python by Taylor Smith(1504)
Django 3 By Example by Antonio Melé(1492)
Interactive Data Visualization with Python by Anshu Kumar & Shubhangi Hora & Sharath Chandra Guntuku & Abha Belorkar(1338)
Hands-On GPU Programming with Python and CUDA by Dr. Brian Tuomanen(1261)
Python Feature Engineering Cookbook by Soledad Galli(1259)
Applied Deep Learning with Keras by Matthew Moocarme Mahla Abdolahnejad and Ritesh Bhagwat(1253)
Hands-On Image Processing with Python by Sandipan Dey(1233)
Python Deep Learning. by Ivan Vasilev(1229)
Scientific Computing with Python 3 by Claus Fuhrer & Jan Erik Solem & Olivier Verdier(1229)
Flask Framework Cookbook by Shalabh Aggarwal(1203)
Training Systems using Python Statistical Modeling by Curtis Miller(1165)
Django 3 Web Development Cookbook - Fourth Edition by Aidas Bendoraitis(1144)