{"id":156,"date":"2023-06-11T20:21:14","date_gmt":"2023-06-11T20:21:14","guid":{"rendered":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/?page_id=156"},"modified":"2023-06-11T20:29:11","modified_gmt":"2023-06-11T20:29:11","slug":"python-strings","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/","title":{"rendered":"Python Strings"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Strings<\/h2>\n<div class=\"tabcontent\">\n\n<h3>What are strings?<\/h3>\n<p>Well you already know, because you&#8217;ve already used them! Strings are a data type that can be used to store characters, numbers, symbols &#8211; pretty much anything!<\/p>\n<p><strong>Advantages of strings<\/strong><\/p>\n<ul>\n<li>Strings can store lots of different types of data, have a look at these different things stored in strings:<\/li>\n<\/ul>\n<p><strong>Disadvantages<\/strong><\/p>\n<ul>\n<li>You can&#8217;t use maths functions with data stored in a string(see the demo)<\/li>\n<\/ul>\n<h3>String Immutability<\/h3>\n<p>Strings, like many other data types, cannot be changed once you have created. This means that if you want to change any data stored in a string, you have to overwrite the whole variable with a new variable.<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Concatenation<\/h2>\n<div class=\"tabcontent\">\n\n<h3>String Concatenation<\/h3>\n<p>Joining two or more strings together is known as string concatenation.<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">String Methods<\/h2>\n<div class=\"tabcontent\">\n\n<h3>String Methods<\/h3>\n<p>Strings have lots of useful methods that make your life easier when coding. Here are a few&#8230;<\/p>\n<p><strong>.capitalize()<\/strong><\/p>\n<p>This capitalizes the first the character in a string ( if it is a letter)<\/p>\n<pre>name = \"bob\"\r\n\r\nprint(name.capitalize())\r\n\r\nBob<\/pre>\n<p><strong>.title()<\/strong><\/p>\n<p>This capitalizes the first the character in a string ( if it is a letter)<\/p>\n<pre>name = \"bob jones\"\r\n\r\nprint(name.title())\r\n\r\nBob Jones<\/pre>\n<p><strong>.upper()<\/strong><\/p>\n<p>THIS CAPITALIZES EVERY LETTER IN THE STRING.<\/p>\n<pre>name = \"bob\"\r\n\r\nprint(name.upper())\r\n\r\nBOB<\/pre>\n<p><strong>.lower()<\/strong><\/p>\n<p>this makes all the letters in the string lower case.<\/p>\n<pre>name = \"bob\"\r\n\r\nprint(name.lower())\r\n\r\nbob<\/pre>\n<p><strong>.count(character)<\/strong><\/p>\n<pre>This counts how many times a character appears in the string.\r\n\r\nname = \"bob\"\r\n\r\nprint(name.count(\"b\"))\r\n\r\n2<\/pre>\n<p><strong>.find(character)<\/strong><\/p>\n<p>Finds the position of the first instance of the character in the string. P.s. Python starts counting at zero, not 1!!!<\/p>\n<pre>greeting = \"hello\"\r\n\r\nprint(greeting.find(\"o\"))\r\n\r\n4<\/pre>\n<p><strong>More methods&#8230;<\/strong><\/p>\n<p>Want to know more methods?<\/p>\n<p>try doing : help(str) in the Interactive Interpreter to find out more string methods.<\/p>\n\n<\/div><h2 class=\"tabtitle\">String to list<\/h2>\n<div class=\"tabcontent\">\n\n\n<\/div><h2 class=\"tabtitle\">Strings challenges<\/h2>\n<div class=\"tabcontent\">\n\n<p>&nbsp;<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>What are strings? Well you already know, because you&#8217;ve already used them! Strings are a data type that can be used to store characters, numbers, symbols &#8211; pretty much anything! Advantages of strings Strings can store lots of different types of data, have a look at these different things stored in strings: Disadvantages You can&#8217;t&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python Strings<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"off","neve_meta_content_width":100,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Strings - Edexcel iGCSE Computer Science<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Strings - Edexcel iGCSE Computer Science\" \/>\n<meta property=\"og:description\" content=\"What are strings? Well you already know, because you&#8217;ve already used them! Strings are a data type that can be used to store characters, numbers, symbols &#8211; pretty much anything! Advantages of strings Strings can store lots of different types of data, have a look at these different things stored in strings: Disadvantages You can&#8217;t&hellip;&nbsp;Read More &raquo;Python Strings\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\" \/>\n<meta property=\"og:site_name\" content=\"Edexcel iGCSE Computer Science\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-11T20:29:11+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\",\"url\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\",\"name\":\"Python Strings - Edexcel iGCSE Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/#website\"},\"datePublished\":\"2023-06-11T20:21:14+00:00\",\"dateModified\":\"2023-06-11T20:29:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Strings\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/#website\",\"url\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/\",\"name\":\"Edexcel iGCSE Computer Science\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Strings - Edexcel iGCSE Computer Science","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/","og_locale":"en_GB","og_type":"article","og_title":"Python Strings - Edexcel iGCSE Computer Science","og_description":"What are strings? Well you already know, because you&#8217;ve already used them! Strings are a data type that can be used to store characters, numbers, symbols &#8211; pretty much anything! Advantages of strings Strings can store lots of different types of data, have a look at these different things stored in strings: Disadvantages You can&#8217;t&hellip;&nbsp;Read More &raquo;Python Strings","og_url":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/","og_site_name":"Edexcel iGCSE Computer Science","article_modified_time":"2023-06-11T20:29:11+00:00","twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/","url":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/","name":"Python Strings - Edexcel iGCSE Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/#website"},"datePublished":"2023-06-11T20:21:14+00:00","dateModified":"2023-06-11T20:29:11+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/python-strings\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/"},{"@type":"ListItem","position":2,"name":"Python Strings"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/#website","url":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/","name":"Edexcel iGCSE Computer Science","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"What are strings? Well you already know, because you&#8217;ve already used them! Strings are a data type that can be used to store characters, numbers, symbols &#8211; pretty much anything! Advantages of strings Strings can store lots of different types of data, have a look at these different things stored in strings: Disadvantages You can&#8217;t&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/pages\/156"}],"collection":[{"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":4,"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/pages\/156\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/pages\/156\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-json\/wp\/v2\/media?parent=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}