{"id":17648,"date":"2020-12-09T02:30:21","date_gmt":"2020-12-09T10:30:21","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=17648"},"modified":"2023-12-01T04:05:46","modified_gmt":"2023-12-01T12:05:46","slug":"python-variables","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-variables\/","title":{"rendered":"Python Variables: A How-To Guide"},"content":{"rendered":"\n<p><em>A Python variable stores a value in a program. Variables have two parts: a label and a value. These two parts are separated by an equals sign (=). You can use the label to refer to the value assigned to the variable throughout your program. Variables can change in value.<\/em><\/p>\n\n\n\n<p>Variables are embedded in programming. Variables allow you to store data in a program that is associated with a particular name.\n\n<\/p>\n\n\n\n<p>For instance, you could have a variable called <em>chocolate<\/em>, which stores a list of chocolates sold at a local grocery store. Or, you could have a variable called <em>username<\/em>, which stores a user\u2019s name for a gaming application.\n\n<\/p>\n\n\n\n<p>This tutorial will discuss, with examples, the basics of variables, and how you can use them in your Python code.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Python Variable?<\/h2>\n\n\n\n<p>A Python variable is a unique identifier for a value. The name assigned to a variable can be used to reference the value assigned to that variable. You can change the value of a variable as many times as you want in your program.<\/p>\n\n\n\n<p>One way of thinking about this is that a variable is a label, which is bound to a particular value in your Python program.<\/p>\n\n\n\n<p>The syntax for a Python variable is:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>chocolate = &quot;Hazelnut&quot;<\/pre><\/div>\n\n\n\n<p>Our variable has three parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>chocolate<\/em> is the name of our variable.<\/li><li><em>=<\/em> is the assignment operator. This operator tells our program we want to assign a value to the label &#8220;chocolate&#8221;.<\/li><li><em>&#8220;Hazelnut&#8221;<\/em> is the value we want to assign to our variable. In this case, the value is a <a href=\"https:\/\/careerkarma.com\/blog\/python-substring\/\">Python string<\/a> object. The double quotes denote a string. Strings can be declared between single quotes, too.<\/li><\/ul>\n\n\n\n<p>Variable types include <a href=\"https:\/\/careerkarma.com\/blog\/python-boolean\/\">Python Booleans<\/a>, <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionaries<\/a>, integers, and floating-point numbers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python: Declare Variable<\/h2>\n\n\n\n<p>Suppose we are building a math app, and we are going to be using the number 3652 many times over in our code. Instead of writing it out manually each time, we could store it in a variable, like so:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>big_number = 3652<\/pre><\/div>\n\n\n\n<p>We have declared a variable called <em>big_number<\/em>. This variable has the value 3652. As a result, when we reference the variable <em>big_number<\/em> in our code, we can access the value 3652.<\/p>\n\n\n\n<p>We have &#8220;declared&#8221; a variable.<\/p>\n\n\n\n<p>Now that we have a variable declared in our code, we can use it throughout our program. So, if we want to see what is stored in our variable, we could use this code:\n\n<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(big_number)<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Python Variables: String Example<\/h3>\n\n\n\n<p>Variables can store any data type, not just numbers. Suppose we want to store a user\u2019s email address in a variable. We could do so using the same approach we used to declare our <em>big_number<\/em> variable from earlier. Here\u2019s an example of a variable which stores a string:\n\n<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>email = &quot;user.email@gmail.com&quot;<\/pre><\/div>\n\n\n\n<p>In our code, we have created a variable called <em>email<\/em> which stores the value <em>user.email@gmail.com<\/em>. If we want to see the value assigned our variable, we can do so by printing it out to the <a href=\"https:\/\/careerkarma.com\/blog\/python-hello-world\/\">Python console<\/a>:\n\n<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(email)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>user.email@gmail.com&lt;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Reassign a Variable<\/h2>\n\n\n\n<p>So far, we have talked through how to declare a variable. This is the process of assigning an initial value to a variable.\n\n<\/p>\n\n\n\n<p>Variables can be changed in Python. This means that after you have declared a variable, you can change the value that it stores.\n\n<\/p>\n\n\n\n<p>Changing the value stored in a variable is an incredibly useful function. For instance, say you are receiving user input in your code. You may want to change the default values to those inserted by the user.\n\n<\/p>\n\n\n\n<p>Take the following variable:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>username = &quot;lassiter202&quot;\nprint(username)\n<\/pre><\/div>\n\n\n\n<p>Our variable is called &#8220;username&#8221;. Our code returns: <em>lassiter202<\/em>. Now, suppose we want to change our user\u2019s username to <em>lassiter303<\/em>. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>username = &quot;lassiter202&quot;\nprint(username)\n\nusername = &quot;lassiter303&quot;\nprint(username)\n<\/pre><\/div>\n\n\n\n<p>Our code returns: <em>lassiter303<\/em>. At the start of our program, the variable <em>username<\/em> stores the value <em>lassiter202<\/em>. So, when we go to print the variable out to the console, the value <em>lassiter202<\/em> is returned.\n\n<\/p>\n\n\n\n<p>Later in our code we reassign the value of the <em>username<\/em> variable to <em>lassiter303<\/em>. This changes the value of our variable. So, when we print out the <em>username<\/em> variable again, the value <em>lassiter303<\/em> is returned, because we reassigned our variable a new value.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Assign Values to Multiple Variables<\/h2>\n\n\n\n<p>In our code above, we assigned one value to a variable per line of code.\n\n<\/p>\n\n\n\n<p>However, it is possible to assign values to multiple variables on one line of code. To do so, we can use a technique called multiple assignment.\n\n<\/p>\n\n\n\n<p>Suppose we want to assign the following values to these variables:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>espresso<\/em> should be equal to 2.10.<\/li><li><em>latte<\/em> should be equal to 2.75.<\/li><li><em>cappuccino<\/em> should be equal to 2.60.<\/li><\/ul>\n\n\n\n<p>We could use the following code to assign these values to their corresponding variables:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>espresso, latte, cappuccino = 2.10, 2.75, 2.60\n\nprint(espresso)\nprint(latte)\nprint(cappuccino)\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>2.10\n2.75\n2.60<\/pre><\/div>\n\n\n\n<p>We were able to assign values to our three variables on one line. We did so by separating out the names of our variables, and the values we wanted to assign to those variables, using commas.\n\n<\/p>\n\n\n\n<p>Similarly, you can assign the same value to multiple variables on one line.\n\n<\/p>\n\n\n\n<p>Suppose we want to assign the value 1 to the variables <em>count1<\/em>, <em>count2<\/em>, and <em>count3<\/em>. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>count1 = count2 = count3 = 1\n\nprint(count1)\nprint(count2)\nprint(count3)\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>1\n1\n1<\/pre><\/div>\n\n\n\n<p>Each of our variables has been assigned the value 1.<\/p>\n\n\n\n<p>These approaches to assigning variables are useful because they allow you to reduce the length of your code. However, you should use these methods of assigning values to variables with caution.<\/p>\n\n\n\n<p>If your code looks confusing with too many multiple assignment statements, you may want to remove a few. This will help you preserve the readability of your work. <\/p>\n\n\n\n<p>The number of values you specify should be equal to the number of labels you identify. Or, you should specify multiple labels and one value. You should not, for instance, specify two labels and seven values. Python would not know what values should be assigned to what labels.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Delete a Python Variable<\/h2>\n\n\n\n<p>There may be a scenario where you want to delete a variable in Python.\n\n<\/p>\n\n\n\n<p>To do so, you can use the Python del statement. The del keyword allows you to delete objects in Python, such as lists, list items, and variables.\n\n<\/p>\n\n\n\n<p>Suppose we have a variable called <em>username<\/em> that we want to delete. We could delete the variable using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>username = &quot;linda101&quot;\n\ndel username\nprint(username)\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>NameError: name \u2018username\u2019 is not defined<\/pre><\/div>\n\n\n\n<p>Our code returns an error when we try to print out the value of the <em>username<\/em> variable. This is because we deleted our variable using the <em>del<\/em> keyword. As soon as <em>del username<\/em> is executed, our variable is deleted and no longer stores any value in our code.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Name a Python Variable<\/h2>\n\n\n\n<p>Every programming language has its own best practices around naming variables.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Style Rules<\/h3>\n\n\n\n<p>Here are the main rules you should keep in mind when naming variables in Python:\n\n<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>They should only contain numbers, letters, and underscore characters.<\/li><li>Variables cannot begin with a number.<\/li><li>They cannot include spaces.<\/li><\/ul>\n\n\n\n<p>So, if you\u2019re storing a user\u2019s email address, the variable name <em>email<\/em> or <em>email_address<\/em> would be acceptable. However, the variable name <em>email address<\/em> or <em>&amp;email_address<\/em> would not work.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Variable Style<\/h3>\n\n\n\n<p>In Python, there are a few style rules that you should keep in mind. These are:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Variables should not start with an uppercase letter.<\/li><li>Using camel case is not preferred. Instead, separating words with underscores is used.<\/li><\/ul>\n\n\n\n<p>So, the variable <em>EmailAddress<\/em> is not considered the best practice, because the variable starts with an uppercase character. Technically, this variable name is valid, but most developers prefer to start their variable names with a lowercase character.\n\n<\/p>\n\n\n\n<p>The variable <em>emailAddress<\/em>, while also still valid, is also not preferred. This is because the variable uses camel case (the second word starts with a capital letter). Our variable does not separate each word in the variable by using an underscore.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Case Sensitivity<\/h3>\n\n\n\n<p>It\u2019s also worth noting that variables are case-sensitive in Python. For instance, the variables <em>email_address<\/em> and <em>emailAddress<\/em> would be considered two different values, because both variables use different cases. However, you should err on the side of caution anyway and avoid writing variables that are too similar, otherwise you may confuse them.\n\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Choosing the Right Name<\/h3>\n\n\n\n<p>Assuming you have followed the rules above, your variable name will be accepted in Python. However, you should still make sure that you pick the right name for a variable. The name you choose should be easy to understand and reflect the purpose of the variable.\n\n<\/p>\n\n\n\n<p>If you want to store a user\u2019s email address, <em>email<\/em> is a good variable name. <em>user_identifier<\/em> is not as clear. Almost anything could be used to identify a user. This would not make for such a good variable name to store a user\u2019s email address.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Python variables store values in a program. You can refer to the name of a variable to access its value. The value of a variable can be changed throughout your program. Variables are declared using this syntax: name = value.<\/p>\n\n\n\n<p>Python variables are useful because they allow you to reduce the need to repeat the same value in your code.<\/p>\n\n\n\n<p>This tutorial discussed how you can use variables in your Python code. Now you\u2019re ready to start working with variables like a Python expert<em><strong><\/strong><\/em><em><strong><\/strong><\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Challenge<\/h2>\n\n\n\n<p>As a challenge, declare a variable with the following attributes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Its name should be &#8220;score&#8221;.<\/li><li>Its value should be 9.<\/li><\/ul>\n\n\n\n<p>Then, use a math operator to multiply the value of &#8220;score&#8221; by two. You should print out the value to the console when you are done.<\/p>\n\n\n\n<p>Next, try to declare three variables called:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>student1grade<\/li><li>student2grade<\/li><li>student3grade<\/li><\/ul>\n\n\n\n<p>These variables should all have the value &#8220;A&#8221;. You should declare all of these variables on the same line because they share the same value.<\/p>\n\n\n\n<p>For advice on top online Python books, courses, and other learning resources, read our complete <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"A Python variable stores a value in a program. Variables have two parts: a label and a value. These two parts are separated by an equals sign (=). You can use the label to refer to the value assigned to the variable throughout your program. Variables can change in value. Variables are embedded in programming.&hellip;","protected":false},"author":240,"featured_media":17650,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-17648","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Variables: A How-To Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Variables: A How-To Guide\" \/>\n<meta property=\"og:description\" content=\"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-09T10:30:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Variables: A How-To Guide\",\"datePublished\":\"2020-12-09T10:30:21+00:00\",\"dateModified\":\"2023-12-01T12:05:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/\"},\"wordCount\":1637,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-variables\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-variables\/\",\"name\":\"Python Variables: A How-To Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg\",\"datePublished\":\"2020-12-09T10:30:21+00:00\",\"dateModified\":\"2023-12-01T12:05:46+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-variables\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-variables\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Variables: A How-To Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Variables: A How-To Guide | Career Karma","description":"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.","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:\/\/careerkarma.com\/blog\/python-variables\/","og_locale":"en_US","og_type":"article","og_title":"Python Variables: A How-To Guide","og_description":"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.","og_url":"https:\/\/careerkarma.com\/blog\/python-variables\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-09T10:30:21+00:00","article_modified_time":"2023-12-01T12:05:46+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Variables: A How-To Guide","datePublished":"2020-12-09T10:30:21+00:00","dateModified":"2023-12-01T12:05:46+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/"},"wordCount":1637,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-variables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-variables\/","url":"https:\/\/careerkarma.com\/blog\/python-variables\/","name":"Python Variables: A How-To Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg","datePublished":"2020-12-09T10:30:21+00:00","dateModified":"2023-12-01T12:05:46+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"A variable is a name that references a value in Python. On Career Karma, learn how to create and work with Python variables.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-variables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/iphone-desk-laptop-notebook-7100.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Variables: A How-To Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=17648"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17648\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/17650"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=17648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=17648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=17648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}