{"id":44,"date":"2026-02-28T12:32:52","date_gmt":"2026-02-28T07:32:52","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=44"},"modified":"2026-03-12T10:45:05","modified_gmt":"2026-03-12T05:45:05","slug":"variables-and-naming-rules","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/","title":{"rendered":"Variables and Naming Rules"},"content":{"rendered":"\n<p>Variables are one of the most fundamental concepts in Python programming. A variable is used to store data or information that can be used and modified later in a program. It acts like a container that holds values such as numbers, text, or other data types.<\/p>\n\n\n\n<p>Understanding how to create variables and follow proper naming rules is essential for writing clean and error free code.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>WHAT IS A VARIABLE<\/strong><\/h1>\n\n\n\n<p>A variable is created when you assign a value to a name using the equals sign.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>x = 10<br>name = &#8220;Ali&#8221;<br>price = 99.99<\/p>\n\n\n\n<p>In the examples above, x, name, and price are variables that store different types of data.<\/p>\n\n\n\n<p>Python automatically detects the data type of the variable based on the assigned value, so you do not need to declare the type separately.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>RULES FOR NAMING VARIABLES<\/strong><\/h1>\n\n\n\n<p>When creating variables in Python, you must follow specific naming rules.<\/p>\n\n\n\n<p>A variable name must start with a letter or an underscore.<br>A variable name cannot start with a number.<br>A variable name can contain letters, numbers, and underscores.<br>A variable name cannot contain spaces.<br>A variable name cannot use special symbols such as @, #, or %.<br>Python keywords such as if, for, while, and class cannot be used as variable names.<\/p>\n\n\n\n<p>Correct examples:<\/p>\n\n\n\n<p>age = 25<br>user_name = &#8220;Hira&#8221;<br>totalMarks = 450<\/p>\n\n\n\n<p>Incorrect examples:<\/p>\n\n\n\n<p>1name = &#8220;Ali&#8221;<br>user-name = &#8220;Sara&#8221;<br>for = 10<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>CASE SENSITIVITY IN VARIABLES<\/strong><\/h1>\n\n\n\n<p>Python is case sensitive. This means that uppercase and lowercase letters are treated differently.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Name = &#8220;Ali&#8221;<br>name = &#8220;Sara&#8221;<\/p>\n\n\n\n<p>These are two different variables.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>BEST PRACTICES FOR VARIABLE NAMES<\/strong><\/h1>\n\n\n\n<p>Use meaningful names that describe the purpose of the variable.<br>Use lowercase letters with underscores for better readability.<br>Avoid very short names unless used in simple loops.<br>Keep names simple and clear.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>student_name = &#8220;Ahmed&#8221;<br>total_marks = 500<\/p>\n\n\n\n<p>Using proper variable names makes your code easier to read, understand, and maintain.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>WHY VARIABLES ARE IMPORTANT<\/strong><\/h1>\n\n\n\n<p>Variables allow you to store and manage data dynamically in your programs. They help in performing calculations, processing user input, and building real world applications.<\/p>\n\n\n\n<p>Mastering variables and naming rules is an important step toward becoming a confident Python programmer.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Variables and Naming Rules<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773292655578\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":6,"template":"","class_list":["post-44","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Variables and Naming Rules - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Variables and Naming Rules - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-12T05:45:05+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. 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\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/variables-and-naming-rules\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/variables-and-naming-rules\\\/\",\"name\":\"Variables and Naming Rules - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-02-28T07:32:52+00:00\",\"dateModified\":\"2026-03-12T05:45:05+00:00\",\"description\":\"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/variables-and-naming-rules\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/variables-and-naming-rules\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/variables-and-naming-rules\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Variables and Naming Rules\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Variables and Naming Rules - One Language. Endless Possibilities","description":"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.","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:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/","og_locale":"en_US","og_type":"article","og_title":"Variables and Naming Rules - One Language. Endless Possibilities","og_description":"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.","og_url":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-12T05:45:05+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/","url":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/","name":"Variables and Naming Rules - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-02-28T07:32:52+00:00","dateModified":"2026-03-12T05:45:05+00:00","description":"Learn Python variables, naming rules, and best practices. Store and manage data dynamically for clean, readable, and error-free code.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/variables-and-naming-rules\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Variables and Naming Rules"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}