{"id":113306,"date":"2025-11-19T11:50:23","date_gmt":"2025-11-19T06:20:23","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=113306"},"modified":"2025-11-17T13:19:30","modified_gmt":"2025-11-17T07:49:30","slug":"python-variables","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/","title":{"rendered":"Python Variables"},"content":{"rendered":"\n<h1 id=\"understanding-python-variables\">Understanding Python Variables<\/h1>\n \n<p>A <strong>Python variable<\/strong> is a named storage location that holds a value. It allows you to label information with a descriptive name, making it easy to access and modify that data throughout your program.<\/p>\n \n<p>Think of a variable as a <strong>labeled box<\/strong>. You can put a value inside (like the number <code>42<\/code>), and whenever you need that number later, you just refer to the box's label (e.g., <code>answer<\/code>).<\/p>\n \n<p>Using variables makes your code flexible. Instead of hard-coding values, you use names that make sense to humans, making your code readable and easier to maintain.<\/p>\n\n<h3 id=\"how-to-create-a-variable\">How to Create a Variable<\/h3>\n<p>In Python, you create a variable through <strong>assignment<\/strong> using the equals sign (<code>=<\/code>). Unlike some other languages, you don't need a special command to declare it first. It happens automatically the moment you assign a value.<\/p>\n \n<ul>\n    <li><code>user_name = \"Ada Lovelace\"<\/code> (String)<\/li>\n    <li><code>user_age = 36<\/code> (Integer)<\/li>\n    <li><code>is_programmer = True<\/code> (Boolean)<\/li>\n<\/ul>\n\n\n\n<h2 id=\"practical-application-creating-variables\">Practical Application: Creating Variables<\/h2>\n<p>The best way to understand variables is to create them yourself. Let's write some code.<\/p>\n\n<h3 id=\"exercise-1-assign-and-print\">Exercise 1: Assign and Print<\/h3>\n<p>Create a variable named <code>greeting<\/code> with the text <code>\"Hello, World!\"<\/code>. Then, create a variable named <code>year<\/code> with the number <code>2025<\/code>. Print both of them.<\/p>\n \n<div class=\"code-editor-container\">\n    <div id=\"editor-1\" class=\"python-code-editor\"># Your code here!\n# 1. Create 'greeting' variable\n# 2. Create 'year' variable\n# 3. Print them both\n<\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-1', 'output-1')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-1', this)\">Show Example<\/button>\n    <\/div>\n    \n    <div id=\"solution-1\" class=\"code-solution\">\n        <pre><code># Define the variables\ngreeting = \"Hello, World!\"\nyear = 2025\n\n# Print them\nprint(greeting)\nprint(year)<\/code><\/pre>\n    <\/div>\n    \n    <label for=\"output-1\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-1\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n\n<h3 id=\"exercise-2-reassigning-variables\">Exercise 2: Reassigning Variables<\/h3>\n<p>Variables are dynamic, their values can change. This is why they are called \"variables\" (able to vary).<\/p>\n<p>In the box below, create a variable called <code>current_status<\/code> and set it to <code>\"Pending\"<\/code>. Print it. Then, on a new line, change the value to <code>\"Complete\"<\/code> and print it again to see the update.<\/p>\n \n<div class=\"code-editor-container\">\n    <div id=\"editor-2\" class=\"python-code-editor\"># Your code here!\n# 1. Set current_status to \"Pending\"\n# 2. Print it\n# 3. Update current_status to \"Complete\"\n# 4. Print it again\n<\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-2', 'output-2')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-2', this)\">Show Example<\/button>\n    <\/div>\n    \n    <div id=\"solution-2\" class=\"code-solution\">\n        <pre><code>current_status = \"Pending\"\nprint(f\"Status is: {current_status}\")\n\n# Reassigning the variable\ncurrent_status = \"Complete\"\nprint(f\"Status is now: {current_status}\")<\/code><\/pre>\n    <\/div>\n    \n    <label for=\"output-2\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-2\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n \n<div class=\"insight-box\">\n    <strong>Analysis:<\/strong> When you assign <code>\"Complete\"<\/code> to the variable, the old value (<code>\"Pending\"<\/code>) is forgotten. The variable name <code>current_status<\/code> now points to the new data.\n<\/div>\n\n\n<h2 id=\"naming-rules-and-best-practices\">Naming Rules and Best Practices<\/h2>\n<p>Python has strict rules and helpful conventions for naming variables. Following these ensures your code runs without errors and is easy for others to read.<\/p>\n \n<ul>\n    <li><strong>The Rules (Mandatory):<\/strong> Names must start with a letter or underscore (<code>_<\/code>). They cannot start with a number. They are case-sensitive (<code>age<\/code> and <code>Age<\/code> are different).<\/li>\n    <li><strong>The Conventions (Best Practice):<\/strong> Use <strong>snake_case<\/strong>. This means using all lowercase letters and separating words with underscores.<\/li>\n    <li><strong>Be Descriptive:<\/strong> Use <code>user_email<\/code> instead of <code>ue<\/code>. Clear names act as documentation for your code.<\/li>\n<\/ul>\n\n<h2 id=\"advanced-concept-dynamic-typing\">Advanced Concept: Dynamic Typing<\/h2>\n<p>Python is <strong>dynamically typed<\/strong>. This means you do not need to tell Python what <em>type<\/em> of data (integer, string, etc.) a variable will hold. Python figures it out automatically.<\/p>\n<p>You can even check what type a variable currently holds using the <code>type()<\/code> function.<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-3\" class=\"python-code-editor\">data = 100\nprint(type(data))\n\ndata = \"One Hundred\"\nprint(type(data))\n\ndata = True\nprint(type(data))\n<\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-3', 'output-3')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-3', this)\">Show Example<\/button>\n    <\/div>\n    \n    <div id=\"solution-3\" class=\"code-solution\">\n        <pre><code># This is the same code as the prompt.\n# Run it to see how the \"type\" changes!\ndata = 100\nprint(type(data)) # <class 'int'>\n\ndata = \"One Hundred\"\nprint(type(data)) # <class 'str'>\n\ndata = True\nprint(type(data)) # <class 'bool'><\/code><\/pre>\n    <\/div>\n    \n    <label for=\"output-3\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-3\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n \n<div class=\"insight-box\">\n    <strong>Analysis:<\/strong> Notice how the type changed from <code>int<\/code> (Integer) to <code>str<\/code> (String) to <code>bool<\/code> (Boolean). While this is flexible, be careful! Changing a variable's type unexpectedly can cause bugs in larger programs.\n<\/div>\n\n<h2 id=\"common-mistakes-to-avoid\">Common Mistakes to Avoid<\/h2>\n<p>Even experienced developers make these small mistakes:<\/p>\n<ul>\n    <li><strong>Unquoted Strings:<\/strong> Writing <code>name = John<\/code> causes an error because Python thinks <code>John<\/code> is another variable. It must be <code>name = \"John\"<\/code>.<\/li>\n    <li><strong>Case Sensitivity:<\/strong> Calling <code>print(Score)<\/code> when you defined <code>score<\/code> (lowercase) will fail.<\/li>\n    <li><strong>Using Keywords:<\/strong> You cannot name a variable <code>if<\/code>, <code>for<\/code>, or <code>class<\/code>, as these are reserved by Python.<\/li>\n<\/ul>\n\n\n<h2 id=\"knowledge-check-apply-your-skills\">Knowledge Check: Apply Your Skills<\/h2>\n<p>Let's simulate a simple shopping cart calculation. In the editor below, define variables for:<\/p>\n \n<ul>\n    <li>An <code>item_name<\/code> (e.g., \"Laptop\")<\/li>\n    <li>An <code>item_price<\/code> (e.g., 500)<\/li>\n    <li>A <code>tax_rate<\/code> (e.g., 0.10)<\/li>\n<\/ul>\n<p>Then, create a new variable called <code>total_cost<\/code> that calculates the price plus tax (Price * Tax Rate + Price). Finally, print a sentence summarizing the order.<\/p>\n \n<div class=\"code-editor-container\">\n    <div id=\"editor-4\" class=\"python-code-editor\"># 1. Define item_name, item_price, and tax_rate\n# 2. Calculate total_cost\n# 3. Print the result\n# Example: \"Total for Laptop is: 550.0\"\n<\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-4', 'output-4')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-4', this)\">Show Answer<\/button>\n    <\/div>\n    \n    <div id=\"solution-4\" class=\"code-solution\">\n    <p>Here is how a professional developer would write this:<\/p>\n    <pre><code># --- Data Variables ---\nitem_name = \"Laptop\"\nitem_price = 1000\ntax_rate = 0.05 # 5% tax\n\n# --- Logic \/ Calculation ---\n# We use variables to do the math\ntax_amount = item_price * tax_rate\ntotal_cost = item_price + tax_amount\n\n# --- Output ---\nprint(f\"Order: {item_name}\")\nprint(f\"Subtotal: {item_price}\")\nprint(f\"Tax: {tax_amount}\")\nprint(f\"Total Due: {total_cost}\")\n<\/code><\/pre>\n<\/div>\n\n<label for=\"output-4\" class=\"output-label\">Output:<\/label>\n<pre id=\"output-4\" class=\"code-output\">Your output will appear here...<\/pre>\n\n<div class=\"cta-final\">\n    <div class=\"cta-final-header\">\n        <span class=\"cta-final-trophy\">\ud83c\udfc6<\/span>\n        <h2 id=\"lesson-completed\">Lesson Completed<\/h2>\n    <\/div>\n    \n    <p class=\"cta-final-intro\">You now understand how to store, name, and manipulate data using Python variables. This is the foundation for all future coding.<\/p>\n    \n    <div class=\"cta-final-grid\">\n        <div class=\"cta-final-option\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcd8<\/span>\n                <h4 id=\"full-python-course\">Full Python Course<\/h4>\n            <\/div>\n            <p>Master Python with 11+ hours of content, 50+ exercises, real-world projects and get a Certificate.<\/p>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming?utm_source=blog\" class=\"cta-final-button-primary\">Enroll Now<\/a>\n        <\/div>\n        \n        <div class=\"cta-final-option\" id=\"pt-next-lesson-container\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcdd<\/span>\n                <h4 id=\"next-lesson\">Next Lesson<\/h4>\n            <\/div>\n            <p id=\"pt-next-lesson-text\">Move on to Data Types.<\/p>\n            <a href=\"#\" id=\"pt-next-lesson-button\" class=\"cta-final-button-secondary\">Next Lesson \u2192<\/a>\n        <\/div>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.<\/p>\n","protected":false},"author":41,"featured_media":113349,"parent":113156,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"templates\/python-tutorial.php","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796,36893],"class_list":["post-113306","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-python","tag-python-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Learn Python Variables<\/title>\n<meta name=\"description\" content=\"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/python\/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\" \/>\n<meta property=\"og:description\" content=\"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Python Variables\",\"datePublished\":\"2025-11-19T06:20:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/\"},\"wordCount\":663,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-variables.webp\",\"keywords\":[\"python\",\"python-tutorial\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/\",\"name\":\"Learn Python Variables\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-variables.webp\",\"datePublished\":\"2025-11-19T06:20:23+00:00\",\"description\":\"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-variables.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-variables.webp\",\"width\":1408,\"height\":768,\"caption\":\"Python Variables\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-variables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Tutorial\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Variables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Learn Python Variables","description":"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.","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:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/","og_locale":"en_US","og_type":"article","og_title":"Python Variables","og_description":"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Python Variables","datePublished":"2025-11-19T06:20:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/"},"wordCount":663,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp","keywords":["python","python-tutorial"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/","url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/","name":"Learn Python Variables","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp","datePublished":"2025-11-19T06:20:23+00:00","description":"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp","width":1408,"height":768,"caption":"Python Variables"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Tutorial","item":"https:\/\/www.mygreatlearning.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Variables"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-variables-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn Python variables with hands-on exercises. Understand assignment, reassignment, naming rules, and dynamic typing. Practice coding directly in your browser.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=113306"}],"version-history":[{"count":9,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113306\/revisions"}],"predecessor-version":[{"id":113348,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113306\/revisions\/113348"}],"up":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/113349"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=113306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=113306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=113306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}