Discover python textbook with exercises, include the articles, news, trends, analysis and practical advice about python textbook with exercises on alibabacloud.com
have the ' K1 ' key, create the ' K1 ' key and its value (the value of the key is set to an empty list), and the index in the list Li is an odd-numbered element that is added to the empty list of the ' K1 ' key.If the dictionary has the ' K1 ' key and the K1 corresponding value is a list type, then the index in the list Li is an even-numbered element that is added to the value corresponding to the ' K1 ' key.Li = [All-in-a, ' a ', ' B ', 4, ' C ']LI1 = []DiC = {' K1 ': li1}If ' K1 ' not in dic:
# Continue's role jumps out of the loop to perform the next loop# Else function is to print a line on the finish of the while print# end= () No Line breaknum = 0While Num Num+=1 If num ==3: Continue #continue function out of the loop to perform the next loop Print (num)Else Print ("00000000000", end= "") Print ("11111111111", end= "")Python Looping exercises
14. Use for loop and range output15. Use for loop and range output 9 * 9 multiplication table16, for the prime number within 100 and. (Programming Questions)17. [1,3,2,7,6,23,41,24,33,85,56] from small to large (bubbling method) (programming)Li = [1,3,2,7,6,23,41,24,33,85,56]for i in Range (Len (LI)-1): # I range 0-9 if li[i] > li[i+1]: # Adjacent two number comparison li[i],li[ I+1] = Li[i+1],li[i]print (LI)Li = [1,3,2,7,6,23,41,24,33,85,56]for i in Range (Len (LI)-1): # I's Range 0-9
# Coding=utf-8import turtle# Draw Pentagram def Drawstar (x): Turtle.begin_fill () for I in range (5): Turtle.forward (x ) Turtle.right (144) Turtle.end_fill () # transfer position def goTo (x, y): turtle.up () Turtle.goto (x, y) Turtle.down () Turtle.setup (864, 576) Turtle.bgcolor ("Red") Turtle.color ("Yellow") Turtle.fillcolor ("Yellow") Turtle.hideturtle () GoTo ( -380, X) Turtle.showturtle () Drawstar () for I in range (4): x = 1 If i in [0, 3]:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.