I used to be reviewing a few of my Python coaching materials, and noticed these traces:
# Multiplying a string by a quantity ends in one other string # with that many copies of the unique string. print "-" * 10 print 10 * '-' print "=" * 10 print 10 * '='
Discover that the integer could be both to the left or proper of the asterisk, and the identical for the string, within the expressions within the print statements above.
Considered experimenting a bit extra, and got here up with these snippets:
print(5 * '=' == '=' * 5) True
print(5 * '=' * 5 == '=' * 5 * 5 == 5 * 5 * '=') True
Which I initially discovered slightly shocking, but when you concentrate on, if comparisons utilizing the less-than or greater-than indicators (or variations like less-than-or-equal and greater-than-or-equal) could be chained in Python, why cannot comparisons utilizing the equals signal be chained too?
This works in each Python 2 and Python three.
– Get pleasure from.
I conduct on-line programs on Python programming, Unix / Linux instructions and shell scripting and SQL programming and database design, with course materials and private teaching classes.
Contact me for particulars after all content material, phrases and schedule.
Attempt FreshBooks: Create and ship skilled wanting invoices in lower than 30 seconds.
Promote your digital merchandise by way of DPD: Digital Publishing for Ebooks and Downloads.
Studying Linux? Hit the bottom working with my vi quickstart tutorial. I wrote it on the request of two Home windows system administrator associates who got further cost of some Unix programs. They later informed me that it helped them to shortly begin utilizing vi to edit textual content information on Unix. In fact, vi/vim is likely one of the most ubiquitous textual content editors round, and works on most different widespread working programs and on some unusual ones too, so the data of the best way to use it would carry over to these programs too.
Take a look at WP Engine, highly effective WordPress internet hosting.
Teachable: feature-packed course creation platform, with limitless video, programs and college students.
Observe me on: