0% found this document useful (0 votes)
3 views1 page

Python Exercises Loops

Uploaded by

Vali Bhasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Exercises Loops

Uploaded by

Vali Bhasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

primes = [2, 3, 5, 7]

for prime in primes:

print(prime)

for x in range(10):

# Check if x is even

if x % 2 == 0:

continue

print(x)
# Python program to illustrate
# Iterating over a list
print("\nList Iteration")
l = ["Welcome", "to", "Python", "World"]
for i in l:
print(i)

# Iterating over a tuple (immutable)


print("\nTuple Iteration")
t = ("Welcome", "to", "Python", "World")
for i in t:
print(i)

# Iterating over a String


print("\nString Iteration")
s = "World"
for i in s:
print(i)

# Iterating over dictionary


print("\nDictionary Iteration")
d = dict()
d['Subject'] = “Python”
d['Text Book'] = “Fundamentals of Python: First Programs”
d['Author'] = “Kenneth A. Lambert”
d['Price'] = “Rs.359.00”

for i in d:
print("%s %d" %(i, d[i]))

for letter in 'geeksforgeeks':


if letter == 'e' or letter == 's':
continue
print 'Current Letter :', letter
var = 10

You might also like