{"id":153,"date":"2016-09-08T20:27:47","date_gmt":"2016-09-08T20:27:47","guid":{"rendered":"http:\/\/cephswift.com\/?page_id=153"},"modified":"2018-08-29T15:35:07","modified_gmt":"2018-08-29T15:35:07","slug":"my-python-script-test-samples","status":"publish","type":"page","link":"https:\/\/cephswift.com\/index.php\/my-python-script-test-samples\/","title":{"rendered":"Python Script Examples"},"content":{"rendered":"<p>Subject: python script<\/p>\n<p>&gt;&gt;&gt; x = 0<br \/>\n&gt;&gt;&gt; while x &lt; 10: &#8230; x += 1 &#8230; print x &#8230; 1 2 3 4 5 6 7 8 9 10 &gt;&gt;&gt; while x &lt; 10: &#8230; print &#8216;x is currently: &#8216;, x &#8230; x += 1 &#8230; else: &#8230; print &#8220;all done !&#8221; &#8230; x is currently: 0 x is currently: 1 x is currently: 2 x is currently: 3 x is currently: 4 x is currently: 5 x is currently: 6 x is currently: 7 x is currently: 8 x is currently: 9 all done ! &gt;&gt;&gt; x = 0<br \/>\n&gt;&gt;&gt; while x &lt; 10: &#8230; x += 1 &#8230; print &#8216;x is currently: &#8216;, x &#8230; else: &#8230; print &#8220;all done !&#8221; &#8230; x is currently: 1 x is currently: 2 x is currently: 3 x is currently: 4 x is currently: 5 x is currently: 6 x is currently: 7 x is currently: 8 x is currently: 9 x is currently: 10 all done ! &gt;&gt;&gt; x = 0<br \/>\n&gt;&gt;&gt; while x &lt; 10: &#8230; print &#8216;x is currently: &#8216;, x &#8230; print &#8216;x is lesss than 10, adding 1&#8217; &#8230; x += 1 &#8230; if x == 3: &#8230; print &#8220;hey x is equals 3 !&#8221; &#8230; else: &#8230; print &#8220;continuing&#8230;.&#8221; &#8230; continue &#8230; x is currently: 0 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 1 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 2 x is lesss than 10, adding 1 hey x is equals 3 ! x is currently: 3 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 4 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 5 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 6 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 7 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 8 x is lesss than 10, adding 1 continuing&#8230;. x is currently: 9 x is lesss than 10, adding 1 continuing&#8230;. &gt;&gt;&gt; range(0,9)<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8]<br \/>\n&gt;&gt;&gt; range(20)<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]<br \/>\n&gt;&gt;&gt; x = range(0,6)<br \/>\n&gt;&gt;&gt; x<br \/>\n[0, 1, 2, 3, 4, 5]<\/p>\n<p>&gt;&gt;&gt; start = 3<br \/>\n&gt;&gt;&gt; stop = 18<br \/>\n&gt;&gt;&gt; range(start,stop)<br \/>\n[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]<\/p>\n<p>&gt;&gt;&gt; range(start,stop,3)<br \/>\n[3, 6, 9, 12, 15]<br \/>\n&gt;&gt;&gt; range(start,stop,2)<br \/>\n[3, 5, 7, 9, 11, 13, 15, 17]<br \/>\n&gt;&gt;&gt; range(start,stop,4)<br \/>\n[3, 7, 11, 15]<br \/>\n&gt;&gt;&gt; for num in range(10):<br \/>\n&#8230; print num<br \/>\n&#8230;<br \/>\n0<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<\/p>\n<p>&gt;&gt;&gt; for num in range(10):<br \/>\n&#8230; print num,<br \/>\n&#8230;<br \/>\n0 1 2 3 4 5 6 7 8 9<br \/>\n&gt;&gt;&gt; for num in xrange(10):<br \/>\n&#8230; print num,<br \/>\n&#8230;<br \/>\n0 1 2 3 4 5 6 7 8 9<br \/>\n&gt;&gt;&gt; for num in xrange(10):<br \/>\n&#8230; print num<br \/>\n&#8230;<br \/>\n0<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n&gt;&gt;&gt; x=xrange(1,6)<br \/>\n&gt;&gt;&gt; x2=range(1,6)<\/p>\n<p>&gt;&gt;&gt; x<br \/>\nxrange(1, 6)<br \/>\n&gt;&gt;&gt; x2<br \/>\n[1, 2, 3, 4, 5]<\/p>\n<p>&gt;&gt;&gt; l = [x for x in range(11) if x % 2 == 0]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 2, 4, 6, 8, 10]<br \/>\n&gt;&gt;&gt; l = [x for x in xrange(0,11) if x % 2 == 0]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 2, 4, 6, 8, 10]<\/p>\n<p>&gt;&gt;&gt; l = [x for x in xrange(0,11) if x % 2 == 1]<br \/>\n&gt;&gt;&gt; l<br \/>\n[1, 3, 5, 7, 9]<\/p>\n<p>&gt;&gt;&gt; l = [x for x in xrange(0,11) if x % 3 == 0]<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; l = [x for x in xrange(0,11) if x % 3 == 0]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 3, 6, 9]<\/p>\n<p>&gt;&gt;&gt; l = [x for x in xrange(0,11) if x % 3 == 1]<br \/>\n&gt;&gt;&gt; l<br \/>\n[1, 4, 7, 10]<br \/>\n&gt;&gt;&gt; celsius = [0,10,20.1,34.5]<br \/>\n&gt;&gt;&gt; fahrenheit = [(temp * (9\/5.0) + 32) for temp in celsius]<br \/>\n&gt;&gt;&gt; fahrenheit<br \/>\n[32.0, 50.0, 68.18, 94.1]<\/p>\n<p>&gt;&gt;&gt; l = [x**2 for x in [x**2 for x in range(11)]]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]<\/p>\n<p>&gt;&gt;&gt; l = [x**4 for x in range(11)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]<\/p>\n<p>&gt;&gt;&gt; X**2<br \/>\n1048576<\/p>\n<p>&gt;&gt;&gt; l = [x**2 for x in range(8)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 1, 4, 9, 16, 25, 36, 49]<\/p>\n<p>&gt;&gt;&gt; l = [x**2 for x in range(3)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 1, 4]<\/p>\n<p>&gt;&gt;&gt; l = [x**2 for x in range(8)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 1, 4, 9, 16, 25, 36, 49]<\/p>\n<p>&gt;&gt;&gt; l = [x**2 for x in (1,2,4,8,16,32,64.128)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[1, 4, 16, 64, 256, 1024, 4112.400384]<\/p>\n<p>&gt;&gt;&gt; 2**1<br \/>\n2<br \/>\n&gt;&gt;&gt; 2**0<br \/>\n1<\/p>\n<p>&gt;&gt;&gt; l = [2**y for y in range(8)]<br \/>\n&gt;&gt;&gt; l<br \/>\n[1, 2, 4, 8, 16, 32, 64, 128]<\/p>\n<p>&gt;&gt;&gt; 2**8 -2<br \/>\n254<br \/>\n&gt;&gt;&gt; 2**7 -2<br \/>\n126<br \/>\n&gt;&gt;&gt; 2**6 -2<br \/>\n62<br \/>\n&gt;&gt;&gt; 2**5 -2<br \/>\n30<br \/>\n&gt;&gt;&gt; 2**4 -2<br \/>\n14<br \/>\n&gt;&gt;&gt; 2**3 -2<br \/>\n6<br \/>\n&gt;&gt;&gt; 2**2 -2<br \/>\n2<\/p>\n<p>&gt;&gt;&gt; l = [x for x in range(10) if x % 2 == 1]<br \/>\n&gt;&gt;&gt; l<br \/>\n[1, 3, 5, 7, 9]<\/p>\n<p>&gt;&gt;&gt; l = [x for x in range(50) if x % 3 == 0]<br \/>\n&gt;&gt;&gt; l<br \/>\n[0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]<\/p>\n<p>&gt;&gt;&gt; st = &#8216;print every word in this stence that has an even number of the letter&#8217;<br \/>\n&gt;&gt;&gt; l = len(st)<br \/>\n&gt;&gt;&gt; l<br \/>\n69<\/p>\n<p>&gt;&gt;&gt; st = &#8216;print every word in this stence that has an even number of the letter&#8217;<br \/>\n&gt;&gt;&gt; st.split()<br \/>\n[&#8216;print&#8217;, &#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<\/p>\n<p>&gt;&gt;&gt; len(st.split())<br \/>\n14<\/p>\n<p>&gt;&gt;&gt; st.split()<br \/>\n[&#8216;print&#8217;, &#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<\/p>\n<p>&gt;&gt;&gt; l = st.split()<\/p>\n<p>&gt;&gt;&gt; l[1]<br \/>\n&#8216;every&#8217;<\/p>\n<p>&gt;&gt;&gt; l[1:]<br \/>\n[&#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<br \/>\n&gt;&gt;&gt; l[0:]<br \/>\n[&#8216;print&#8217;, &#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<\/p>\n<p>&gt;&gt;&gt; l[0:]<br \/>\n[&#8216;print&#8217;, &#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<br \/>\n&gt;&gt;&gt; len(l[0:])<br \/>\n14<br \/>\n&gt;&gt;&gt; len(l[0:5])<br \/>\n5<br \/>\n&gt;&gt;&gt; len(l[0])<br \/>\n5<\/p>\n<p>&gt;&gt;&gt; l = range(100)<br \/>\n&gt;&gt;&gt; print l<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]<\/p>\n<p>&gt;&gt;&gt; st = &#8216;print every word in this stence that has an even number of the letter&#8217;<br \/>\n&gt;&gt;&gt; st.split()<br \/>\n[&#8216;print&#8217;, &#8216;every&#8217;, &#8216;word&#8217;, &#8216;in&#8217;, &#8216;this&#8217;, &#8216;stence&#8217;, &#8216;that&#8217;, &#8216;has&#8217;, &#8216;an&#8217;, &#8216;even&#8217;, &#8216;number&#8217;, &#8216;of&#8217;, &#8216;the&#8217;, &#8216;letter&#8217;]<br \/>\n&gt;&gt;&gt; st.split()[0]<br \/>\n&#8216;print&#8217;<br \/>\n&gt;&gt;&gt; st.split()[0][0]<br \/>\n&#8216;p&#8217;<br \/>\n&gt;&gt;&gt; st.split()[0::][0]<br \/>\n&#8216;print&#8217;<br \/>\n&gt;&gt;&gt; st.split()[1][0]<br \/>\n&#8216;e&#8217;<\/p>\n<p>&gt;&gt;&gt; st = &#8216;print only the words that start with s in this sentance&#8217;<br \/>\n&gt;&gt;&gt; for w in st.split():<br \/>\n&#8230; if w[0] == &#8216;s&#8217;:<br \/>\n&#8230; print w<br \/>\n&#8230;<br \/>\nstart<br \/>\ns<br \/>\nsentance<br \/>\n&gt;&gt;&gt; st = &#8216;print every word in this sentance that has even number of letter&#8217;<br \/>\n&gt;&gt;&gt; for w in st.split():<br \/>\n&#8230; if len(w)%2 == 0:<br \/>\n&#8230; print w + &#8220;&#8212;&gt; has an even length !&#8221;<br \/>\n&#8230;<br \/>\nword&#8212;&gt; has an even length !<br \/>\nin&#8212;&gt; has an even length !<br \/>\nthis&#8212;&gt; has an even length !<br \/>\nsentance&#8212;&gt; has an even length !<br \/>\nthat&#8212;&gt; has an even length !<br \/>\neven&#8212;&gt; has an even length !<br \/>\nnumber&#8212;&gt; has an even length !<br \/>\nof&#8212;&gt; has an even length !<br \/>\nletter&#8212;&gt; has an even length !<br \/>\n&gt;&gt;&gt;<\/p>\n<p>&gt;&gt;&gt; def vol(red):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0return (4.0\/3)*(3.14)<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; vol<\/p>\n<p>&gt;&gt;&gt; (4.0\/3)*(3.14)<br \/>\n4.1866666666666665<br \/>\n&gt;&gt;&gt; def vol():<br \/>\n&#8230; return (4.0\/3)*(3.14)*(red**3)<br \/>\n&#8230;<\/p>\n<p>&gt;&gt;&gt; def ran_check(num,low,high):<br \/>\n&#8230; if num in range(low,high):<br \/>\n&#8230; print &#8221; %s is in the range&#8221; %str(num)<br \/>\n&#8230; else:<br \/>\n&#8230; print &#8220;The number is out the range.&#8221;<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; ran_check(3,1,10)<br \/>\n3 is in the range<br \/>\n&gt;&gt;&gt; ran_check(11,1,10)<br \/>\nThe number is out the range.<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; def ran_check(num,low,high):<br \/>\n&#8230; if num in range(low,high):<br \/>\n&#8230; print &#8221; %s is in the range&#8221; %str(num)<br \/>\n&#8230; else:<br \/>\n&#8230; print &#8220;The number is out the range.&#8221;<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; ran_check(11,1,10)<br \/>\nThe number is out the range.<br \/>\n&gt;&gt;&gt; ran_check(6,1,10)<br \/>\n6 is in the range<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; def up_low(s):<br \/>\n&#8230; d={&#8220;upper&#8221;:0, &#8220;lower&#8221;:0}<br \/>\n&#8230; for c in s:<br \/>\n&#8230; if c.isupper():<br \/>\n&#8230; d[&#8220;upper&#8221;]+=1<br \/>\n&#8230; elif c.islower():<br \/>\n&#8230; d[&#8220;lower&#8221;]+=1<br \/>\n&#8230; else:<br \/>\n&#8230; pass<br \/>\n&#8230; print &#8220;Original String : &#8220;, s<br \/>\n&#8230; print &#8220;No. of Upper case characters : &#8220;, d[&#8220;upper&#8221;]<br \/>\n&#8230; print &#8220;No. of Lower case characters : &#8220;, d[&#8220;lower&#8221;]<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; s = &#8220;Hello Mr. Rogers, How are you this fine Tuesday ? &#8221;<br \/>\n&gt;&gt;&gt; up_lows()<br \/>\nTraceback (most recent call last):<br \/>\nFile &#8220;&#8221;, line 1, in<br \/>\nNameError: name &#8216;up_lows&#8217; is not defined<br \/>\n&gt;&gt;&gt; up_low(s)<br \/>\nOriginal String : Hello Mr. Rogers, How are you this fine Tuesday ?<br \/>\nNo. of Upper case characters : 5<br \/>\nNo. of Lower case characters : 32<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; def uniq_list(l):<br \/>\n&#8230; x = []<br \/>\n&#8230; for a in l:<br \/>\n&#8230; if a not in x:<br \/>\n&#8230; x.append()<br \/>\n&#8230; return x<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; uniq_list([1,1,1,1,2,2,2,3,3,3,3,4,5])<\/p>\n<p>&gt;&gt;&gt; def uniq_list(l):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0x = []<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0for a in l:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0if a not in x:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 x.append(a)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return x<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; uniq_list([1,1,1,1,2,2,2,3,3,3,3,4,5])<br \/>\n[1, 2, 3, 4, 5]<br \/>\n&gt;&gt;&gt;<\/p>\n<p>&gt;&gt;&gt; def uniq_list2(l):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 a = set([])<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ret = []<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 for x in l:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if x not in a:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ret.append(x)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 a.add(x)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0return ret<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; uniq_list2([1,1,1,1,2,2,2,3,3,3,3,4,5])<br \/>\n[1, 2, 3, 4, 5]<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt; def multiply(numbers):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0total = numbers[0]<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0for x in numbers:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 total *= x<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return total<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; multiply([1,2,3,-4])<br \/>\n-24<\/p>\n<p>&gt;&gt;&gt; def plyer_choice(board):<br \/>\n&#8230; pass<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; range (1,20)<br \/>\n[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]<br \/>\n&gt;&gt;&gt; range (1,10)<br \/>\n[1, 2, 3, 4, 5, 6, 7, 8, 9]<br \/>\n&gt;&gt;&gt; range (0,10)<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<br \/>\n&gt;&gt;&gt; range (0,-1)<br \/>\n[]<br \/>\n&gt;&gt;&gt; range (0,10)[3:7]<br \/>\n[3, 4, 5, 6]<\/p>\n<p>&gt;&gt;&gt; range (0,10)[-2:]<br \/>\n[8, 9]<\/p>\n<p>&gt;&gt;&gt; range (0,10)[-1:]<br \/>\n[9]<br \/>\n&gt;&gt;&gt; range (0,10)[-1:3]<br \/>\n[]<br \/>\n&gt;&gt;&gt; range (0,10)[-1:-3]<br \/>\n[]<br \/>\n&gt;&gt;&gt; range (0,10)[-1::]<br \/>\n[9]<br \/>\n&gt;&gt;&gt; range (0,10)[::1]<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<\/p>\n<p>&gt;&gt;&gt; range (0,10)[::]<br \/>\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<\/p>\n<p>&gt;&gt;&gt; range (0,10)[::-1]<br \/>\n[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]<br \/>\n&gt;&gt;&gt; range (0,10)[::-3]<br \/>\n[9, 6, 3, 0]<\/p>\n<p>&gt;&gt;&gt; class Sample(object):<br \/>\n&#8230; pass<br \/>\n&#8230;<\/p>\n<p>&gt;&gt;&gt; st = &#8221; Print only the word that start with s in this sentence&#8221;<br \/>\n&gt;&gt;&gt; for w in st.split():<br \/>\n&#8230; if w[0] == &#8216;s&#8217;:<br \/>\n&#8230; print w<br \/>\n&#8230;<br \/>\nstart<br \/>\ns<br \/>\nsentence<\/p>\n<p>===================================<\/p>\n<p>Function test example:<\/p>\n<p>$ cat test_function_2.py<br \/>\ndef sumProblem(x, y):<br \/>\nsum = x + y<br \/>\nsentence = &#8216;The sum of {} and {} is {}.&#8217;.format(x, y, sum)<br \/>\nprint(sentence)<\/p>\n<p>def main():<br \/>\nsumProblem(2, 3)<br \/>\nsumProblem(1234567890123, 535790269358)<br \/>\na = int(input(&#8220;Enter an integer: &#8220;))<br \/>\nb = int(input(&#8220;Enter another integer: &#8220;))<br \/>\nsumProblem(a, b)<\/p>\n<p>main()<\/p>\n<p>=================================<\/p>\n<p>Run the script line by line:<\/p>\n<p>$ python<br \/>\nPython 2.7.12 (default, Dec 4 2017, 14:50:18)<br \/>\n[GCC 5.4.0 20160609] on linux2<br \/>\nType &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>\n&gt;&gt;&gt; def sumProblem(x, y):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sum = x + y<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sentence = &#8216;The sum of {} and {} is {}.&#8217;.format(x, y, sum)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print(sentence)<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; def main():<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0sumProblem(2, 3)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0sumProblem(1234567890123, 535790269358)<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0a = int(input(&#8220;Enter an integer: &#8220;))<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0b = int(input(&#8220;Enter another integer: &#8220;))<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0sumProblem(a, b)<br \/>\n&#8230;<br \/>\n&gt;&gt;&gt; main()<br \/>\nThe sum of 2 and 3 is 5.<br \/>\nThe sum of 1234567890123 and 535790269358 is 1770358159481.<br \/>\nEnter an integer: 45<br \/>\nEnter another integer: 67<br \/>\nThe sum of 45 and 67 is 112.<br \/>\n&gt;&gt;&gt;<\/p>\n<p>&gt;&gt;&gt; for l in xrange(1,101):<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0if l % 3 == 0 and l % 5 == 0:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print &#8220;FizzBuzz&#8221;<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0elif l% 3 == 0:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print &#8220;Fizz&#8221;<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0elif l% 5 == 0:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print &#8220;Buzz&#8221;<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 else:<br \/>\n&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print l,<br \/>\n&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Subject: python script &gt;&gt;&gt; x = 0 &gt;&gt;&gt; while x &lt; 10: &#8230; x += 1 &#8230; print x &#8230; 1 2 3 4 5 6 7 8 9 10 &gt;&gt;&gt; while x &lt; 10: &#8230; print &#8216;x is currently: &#8216;, x &#8230; x += 1 &#8230; else: &#8230; print &#8220;all done !&#8221; &#8230; x [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/pages\/153"}],"collection":[{"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":7,"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/pages\/153\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/pages\/153\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/cephswift.com\/index.php\/wp-json\/wp\/v2\/media?parent=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}