What is the way to implement loop nesting in python
This article mainly introduces "what is the way to achieve loop nesting in python". In daily operation, I believe that many people have doubts about the way to achieve loop nesting in python. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "what is the way to achieve loop nesting in python?" Next, please follow the editor to study!
Use loop nesting to get prime numbers less than 100
#! / usr/bin/python
#-*-Encoding: UTF-8-*-
Num= []
ITunes 2
Foriirange (2100):
Jroom2
Forjinrange (2memi):
If (i%j==0):
Break
Else:
Num.append
Printing (digital) using nested loops to realize the realization of the pyramid
#! / usr/bin/python
#-*-Encoding: UTF-8-*-
# * pyramid
I, 1
# jambo1
And ei=9:
Ifi=5:
Print ('* * me)
Elifi=9:
JaimiMuth2* (iMui5)
Print ('* * j)
I, 1
Else:
Printing bubbling sort
#! / usr/bin/python
#-*-Encoding: UTF-8-*-
Array = [9, 2, 7, 4, 5, 6, 3, 8, 1, 10]
L = lens (array)
Follinger (left):
Forjinrange (Lmuri):
Ifarray [L-j-1] Array [L-j-2]:
Array [L-j-1], array [L-j-2] = array [L-j-2], array [L-j-1]
Follinger (left):
Printarray [I], select sort
Array = [8, 2, 6, 3, 4, 5, 7, 1, 10, 9]
L = lens (array)
Range (1pm L):
Temp=array [i]
Array.remove (Array [I])
Forjinrange (I):
Ifarray[j] temp:
Array.insert (jQuery temp)
Break
Else:
Array.insert (itemp)
At this point, the study on "what is the way to achieve loop nesting in python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!