Python line of code will be able to get things done!

Source: Internet
Author: User

To print the 9*9 multiplication table:

Print ' \ n '. Join ([') '. Join (['%s*%s=%-2s' for in  for  in range (1,10)]) 1*1=11*2=2  2*2=41*3=3  2*3=6  3*3=91*4=4  2*4=8  4=12 4*4=161*5=5  2*5=10 3*5=15 4*5=20 5*5=251*6=6  2*6=12 3*6=18 4*6=24 5*6=30 6*6=361*7=7  2*7=14 3*7=21 4 *7=28 5*7=35 6*7=42 7*7=491*8=8  2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=641*9=9  2*9=18 3*9=27 4*9=36 5*9=4 5 6*9=54 7*9=63 8*9=72 9*9=81>>>

A line of code calculates the prime number between 1-1000:

>>>Print(* (i forIinchRange (2, 1000)ifAll (Tuple (i%j forJinchRange (2, int (i**.5))))))2 3 4 5 6 7 8 9 11 13 15 17 19 23 25 29 31 35 37 41 43 47 49 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 121 127 131 137 139 143 149 151 157 163 167 169 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 2  83 289 293 307 311 313 317 323 331 337 347 349 353 359 361 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 529 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 6  47 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 841 853 857 859 863 877 881 883 887 899 907 911 919 929 937 941 947 953 961 967 971 977 983 991 997>>>

How many of the numbers can be divisible by 123 within 5000?

 for  in range (123,5000,123)])40

A word to print?

Print ('\ n'. Join (['nnnn'[(x-y)% len ('  nnnn'ifelse' for in  for  in range (30,-30,-1)])

Python line of code will be able to get things done!

Related Article

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.