Python written by Little 99

Source: Internet
Author: User

Learn the Python loop statement, four ways to achieve the 99 multiplication table.

Def jiujiuwhile (a): "Use while for Loop" "I=1 while I<=a:j=1 while J<=i:print "%d X%d =%d\t"% (j,i,i*j), j+=1 i+=1 Print




Def jiujiufor (a): "' Use for For loop ' ' for I in range (1, a+1): for J in range (1, i+1): print" %d x%d =%d\t "% (j,i,j*i), print





Def thisline (a): print "1 x%d =%d"% (a,a), for I in Range (2,a+1): print "\t%d X%d =%d"% (i,a,i*a), Print


def Jiujiudigui (m): if M>1:jiujiudigui (m-1) thisline (m) elif M==1:thisline (1)

Def jiujiulist (a): "How can I use the map () function to calculate this two-dimensional small 99 array at once?" How can you display it in a more canonical format like the previous function? ' For I in Range (1,a+1): Print map (lambda x: "%d x%d =%d"% (x,i,x*i), Range (1,i+1))


Jiujiufor (9) jiujiuwhile (9) Jiujiudigui (9) jiujiulist (9)


This article is from "It changes us" blog, please make sure to keep this source http://charlywoo.blog.51cto.com/4013957/1542979

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.