{"id":2644,"date":"2019-08-13T15:03:25","date_gmt":"2019-08-13T15:03:25","guid":{"rendered":"https:\/\/old.staging-teachcomputerscienceuk.kinsta.cloud\/?p=320"},"modified":"2024-07-24T10:09:26","modified_gmt":"2024-07-24T10:09:26","slug":"programming-data-types","status":"publish","type":"post","link":"https:\/\/teachcomputerscience.com\/programming-data-types\/","title":{"rendered":"Programming Data Types"},"content":{"rendered":"<div class=\"gb-container gb-container-81d031df upsell-block\"><div class=\"gb-inside-container\">\n<div class=\"gb-grid-wrapper gb-grid-wrapper-07430ab4\">\n<div class=\"gb-grid-column gb-grid-column-58412a74\"><div class=\"gb-container gb-container-58412a74\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-693906d5 gb-headline-text\">GCSE Data Representation (14-16 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-7dcb2af3\">\n\n<a class=\"gb-button gb-button-2ae50b61 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/gcse\/data-representation\/\">View GCSE Data Representation Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n\n<div class=\"gb-grid-column gb-grid-column-b6a491fa\"><div class=\"gb-container gb-container-b6a491fa\"><div class=\"gb-inside-container\">\n\n<h2 class=\"gb-headline gb-headline-3587a766 gb-headline-text\">A-Level Data types, data structures and algorithms (16-18 years)<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>An editable PowerPoint lesson presentation<\/li><li>Editable revision handouts<\/li><li>A glossary which covers the key terminologies of the module<\/li><li>Topic mindmaps for visualising the key concepts<\/li><li>Printable flashcards to help students engage active recall and confidence-based repetition<\/li><li>A quiz with accompanying answer key to test knowledge and understanding of the module<\/li><\/ul>\n\n\n<div class=\"gb-button-wrapper gb-button-wrapper-abc7e985\">\n\n<a class=\"gb-button gb-button-2c807822 gb-button-text\" href=\"https:\/\/teachcomputerscience.com\/a-level\/data-types-data-structures-and-algorithms\/\">View A-Level Data types, data structures and algorithms Resources<\/a>\n\n<\/div>\n<\/div><\/div><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\">Programming Data Types<\/h2>\n\n\n\n<p>A\u00a0<strong>data type<\/strong>\u00a0is a means of classifying the type of data that a\u00a0variable\u00a0or\u00a0object can hold in computer programming.\u00a0 Data types are an important factor in all computer programming languages, including\u00a0C#,\u00a0C++,\u00a0JavaScript, and\u00a0Visual Basic.\u00a0 When programmers develop computer software\u2014whether that\u2019s desktop or web-based\u2014data types must be assigned and applied correctly in order to guarantee proper outcomes and an error-free program.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/031-edit-code-1.png\" alt=\"programming data types\" class=\"wp-image-5787\" width=\"228\" height=\"228\" title=\"\" srcset=\"https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/031-edit-code-1.png 512w, https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/031-edit-code-1-150x150.png 150w, https:\/\/teachcomputerscience.com\/wp-content\/uploads\/2019\/08\/031-edit-code-1-300x300.png 300w\" sizes=\"auto, (max-width: 228px) 100vw, 228px\" \/><\/figure><\/div>\n\n\n\n<p>In programming, a data type is a categorization that specifies what kind of operation can be applied to it without resulting in an error.<\/p>\n\n\n\n<p>The data type determines which&nbsp;operations can be safely executed to develop, transpose, and apply the variable to another computation.&nbsp; When a programming language needs a <a href=\"http:\/\/teachcomputerscience.com\/variables-and-constants\/\">variable<\/a> to be used only in ways that follow its data type, that language is said to be&nbsp;<em>strongly typed<\/em>.&nbsp; Doing this reduces errors because while it is reasonable to ask the computer to multiply a float by an integer (3.4 x 3), it is unreasonable to ask the computer to multiply a float by a string (3.4 x Sam).&nbsp; When a programming language allows a variable to assume a different data type, the language is said to be&nbsp;<em>weakly typed<\/em>.<\/p>\n\n\n\n<p>Strongly typed&nbsp;and&nbsp;weakly typed&nbsp;programming languages are commonly-held misconceptions.&nbsp; There is a concept of type safety, whereby a programming language constraints or restricts type error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Data Types<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Integer<\/strong> \u2013 a whole number that can have a positive, negative, or zero value. It cannot be a fraction, nor can it include decimal places.&nbsp; It is commonly used in programming, especially for increasing values.&nbsp; Addition, subtraction, and multiplication of two integers results in an integer.&nbsp; However, division of two integers may result in either an integer or a decimal.&nbsp; The resulting decimal can be rounded off or truncated in order to produce an integer.<\/li><li><strong>Character<\/strong> \u2013 any number, letter, space, or symbol that can be entered in a computer. Every character occupies one byte of space.<\/li><li><strong>String<\/strong> \u2013 used to represent text. It is composed of a set of characters that can include spaces and numbers.&nbsp; Strings are enclosed in quotation marks to identify the data as strings, and not as variable names, nor as numbers.<\/li><li><strong>Floating Point Number<\/strong> \u2013 a <a href=\"http:\/\/teachcomputerscience.com\/numbers\/\">number<\/a> that contains decimals. Numbers that contain fractions are also considered floating-point numbers.<\/li><li><strong>Array<\/strong> \u2013 a kind of a list that contains a group of elements which can be of the same data type as an integer or string. It is used to organise data for easier sorting and searching of related sets of values.<\/li><li><strong>Varchar<\/strong> &#8211; as the name implies, a varchar is a variable character, on account of the fact that the memory storage has variable length.&nbsp; Each character occupies one byte of space, plus 2 bytes additional for length information.<\/li><\/ul>\n\n\n\n<p><em>Note: Use Character for data entries with fixed lengths, like phone numbers, but use Varchar for data entries with variable lengths, like an address.<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Boolean<\/strong> \u2013 used for creating true or false statements. To compare values the following operators are being used: AND, OR, XOR, and NOT.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table rcp-table\"><table><tbody><tr><th><b>Boolean Operator<\/b><\/th><th><b>Result<\/b><\/th><th><b>Condition<\/b><\/th><\/tr><tr><td>x AND y<\/td><td>True<\/td><td>If both x and y are True<\/td><\/tr><tr><td>x AND y<\/td><td>False<\/td><td>If either x or y is False<\/td><\/tr><tr><td>x OR y<\/td><td>True<\/td><td>If either x or y, or both x and y are True<\/td><\/tr><tr><td>x OR y<\/td><td>False<\/td><td>If both x and y are False<\/td><\/tr><tr><td>x XOR y<\/td><td>True<\/td><td>If only x or y is True<\/td><\/tr><tr><td>x XOR y<\/td><td>False<\/td><td>If x and y are both True or both False<\/td><\/tr><tr><td>NOT x<\/td><td>True<\/td><td>If x is False<\/td><\/tr><tr><td>NOT x<\/td><td>False<\/td><td>If x is True<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Date, Time and Timestamp<\/strong> \u2013 these data types are used to work with data containing dates and times.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table rcp-table\"><table><tbody><tr><th><b>Date Type<\/b><\/th><th><b>Value<\/b><\/th><\/tr><tr><td>DATE<\/td><td>Year, Month and Day<\/td><\/tr><tr><td>TIME<\/td><td>Hour, Minute and Second<\/td><\/tr><tr><td>TIMESTAMP<\/td><td>Year, Month, Day, Hour, Minute, Second and Microsecond<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Further Reading<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Data_type\" target=\"_blank\" rel=\"noopener\">Data type<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Programming Data Types A\u00a0data type\u00a0is a means of classifying the type of data that a\u00a0variable\u00a0or\u00a0object can hold in computer programming.\u00a0 Data types are an important factor in all computer programming languages, including\u00a0C#,\u00a0C++,\u00a0JavaScript, and\u00a0Visual Basic.\u00a0 When programmers develop computer software\u2014whether that\u2019s desktop or web-based\u2014data types must be assigned and applied correctly in order to guarantee proper &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Programming Data Types\" class=\"read-more button\" href=\"https:\/\/teachcomputerscience.com\/programming-data-types\/\" aria-label=\"More on Programming Data Types\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_generate-full-width-content":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14],"tags":[204,47],"class_list":["post-2644","post","type-post","status-publish","format-standard","hentry","category-programming","tag-article","tag-hide-old-upsell","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"acf":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/comments?post=2644"}],"version-history":[{"count":4,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2644\/revisions"}],"predecessor-version":[{"id":683937,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/posts\/2644\/revisions\/683937"}],"wp:attachment":[{"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/media?parent=2644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/categories?post=2644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teachcomputerscience.com\/wp-json\/wp\/v2\/tags?post=2644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}