Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":13561,"date":"2015-05-05T11:57:18","date_gmt":"2015-05-05T16:57:18","guid":{"rendered":"https:\/\/ismalga.withknown.com\/2015\/creation-and-use-of-strings-in-python-mastery-26"},"modified":"2015-05-05T11:57:18","modified_gmt":"2015-05-05T16:57:18","slug":"creation-and-use-of-strings-in-python-mastery-26","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2015\/2015\/creation-and-use-of-strings-in-python-mastery-26\/","title":{"rendered":"Creation and Use of Strings in Python. Mastery 26."},"content":{"rendered":"
\n

<\/p>\n

<\/p>\n

A string is a sequence of characters. You can access the characters one at a time with the bracket operator. <\/span><\/p>\n

Per example, let\u2019s declare a string variable called car<\/em> containing a sequence of characters forming the word mazda6<\/em>. <\/span><\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

In this example I\u2019m calling the character corresponding to the third value of index of characters. Remember that the index starts at 0, so the character 0 will be c, the character 1 a, the character 2 z and so on. <\/span><\/p>\n

Len. <\/span><\/strong><\/p>\n

The function len is able to return the numbers of characters contained in a string. Example: <\/span><\/p>\n

\u00a0<\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

If you want to get the last character of a string you can try something like this: <\/span><\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

Traversal. <\/span><\/strong><\/p>\n

The process of dealing one string character at time and doing something to it, is called traversal processing. <\/span><\/p>\n

Example: <\/span><\/p>\n

\"\"\"\"<\/p>\n

<\/p>\n

<\/p>\n

This prints individually each of the characters contained inside the car string. <\/span><\/p>\n

Slices. <\/span><\/strong><\/p>\n

Slices are segment of strings. Selecting slices of a certain strings is really easy. <\/span><\/p>\n

Example: <\/span><\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

The slice that I\u2019m calling in this example is one going from the index 0 to the 4th<\/sup> index. Notice that using the 5 in the brackets means calling the previous character in the index. So the bracket works something like this [firstindex:lastindex+1].<\/span><\/p>\n

Because\u2026<\/span><\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

Immutability. <\/span><\/strong><\/p>\n

Strings are immutable, that meaning that you are not able to change an existing string. The best thing you can do to deal with this is creating a new string that is a variation from the original. <\/span><\/p>\n

Example, let\u2019s call a new model \u2018mazda3\u2019:<\/span><\/p>\n

\"\"<\/p>\n

<\/p>\n

<\/p>\n

You can appreciate that I\u2019m calling the slice that contains the word \u2018mazda\u2019 and I\u2019m adding a \u20183\u2019 to the end, so I have a new string called new model containing the string \u2018Mazda3\u2019<\/strong><\/span><\/p>\n

Counting. <\/span><\/strong><\/p>\n

Also, you can go a little forward and count the times that a character appears in a string. Let\u2019s count how many times the \u2018a\u2019 appears in \u2018Mazda6\u2019.<\/span><\/p>\n

\"\"\"\"<\/p>\n

\u00a0<\/p>\n

<\/p>\n

<\/p>\n

These are somes of the things that you can do with a string. Have fun \ud83d\ude00 <\/span><\/p>\n

\u00a0<\/p>\n

\u00a0<\/p>\n

#Mastery<\/a>26<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

A string is a sequence of characters. You can access the characters one at a time with the bracket operator. <\/span><\/p>\n

Per example, let’s declare a string variable called car<\/em> containing a sequence of characters forming the word mazda6<\/em>. <\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

In this example I’m calling the character corresponding to the third value of index of characters. Remember that the index starts at 0, so the character 0 will be c, the character 1 a, the character 2 z and so on. <\/span><\/p>\n

Len. <\/span><\/strong><\/p>\n

The function len is able to return the numbers of characters contained in a string. Example: <\/span><\/p>\n

 <\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

If you want to get the last character of a string you can try something like this: <\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

Traversal. <\/span><\/strong><\/p>\n

The process of dealing one string character at time and doing something to it, is called traversal processing. <\/span><\/p>\n

Example: <\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

This prints individually each of the characters contained inside the car string. <\/span><\/p>\n

Slices. <\/span><\/strong><\/p>\n

Slices are segment of strings. Selecting slices of a certain strings is really easy. <\/span><\/p>\n

Example: <\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

The slice that I’m calling in this example is one going from the index 0 to the 4th<\/sup> index. Notice that using the 5 in the brackets means calling the previous character in the index. So the bracket works something like this [firstindex:lastindex+1].<\/span><\/p>\n

Because…<\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

Immutability. <\/span><\/strong><\/p>\n

Strings are immutable, that meaning that you are not able to change an existing string. The best thing you can do to deal with this is creating a new string that is a variation from the original. <\/span><\/p>\n

Example, let’s call a new model ‘mazda3’:<\/span><\/p>\n<\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

You can appreciate that I’m calling the slice that contains the word ‘mazda’ and I’m adding a ‘3’ to the end, so I have a new string called new model containing the string ‘Mazda3’<\/strong><\/span><\/p>\n

Counting. <\/span><\/strong><\/p>\n

Also, you can go a little forward and count the times that a character appears in a string. Let’s count how many times the ‘a’ appears in ‘Mazda6’.<\/span><\/p>\n<\/p>\n

 <\/p>\n

<\/p>\n

<\/p>\n

Normal
\n 0<\/p>\n

21<\/p>\n

false
\n false
\n false<\/p>\n

ES-MX
\n X-NONE
\n X-NONE<\/p>\n

<\/p>\n

<\/p>\n

\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n

These are somes of the things that you can do with a string. Have fun \ud83d\ude00 <\/span><\/p>\n

 <\/p>\n

 <\/p>\n

#Mastery<\/a>26<\/p>\n<\/div>\n

Continue reading →<\/span><\/a><\/p>\n","protected":false},"author":104,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,25],"tags":[186,243,287],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/users\/104"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/comments?post=13561"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561\/revisions"}],"predecessor-version":[{"id":17540,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561\/revisions\/17540"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/media?parent=13561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/categories?post=13561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/tags?post=13561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}