{"id":317,"date":"2025-12-17T10:31:26","date_gmt":"2025-12-17T10:31:26","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=317"},"modified":"2025-12-17T11:34:28","modified_gmt":"2025-12-17T11:34:28","slug":"%f0%9f%93%98-lesson-2-python-syntax-and-variables-examples","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=317","title":{"rendered":"\ud83d\udcd8 Lesson 2 examples: Python Syntax and Variables examples"},"content":{"rendered":"\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-831b2db5 wp-block-group-is-layout-flex\">\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1\ufe0f\u20e3 Creating Variables<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"Sameer\"\nage = 25\nsalary = 35000\nis_employee = True\n\nprint(name)\nprint(age)\nprint(salary)\nprint(is_employee)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Sameer\n25\n35000\nTrue\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2\ufe0f\u20e3 Variables with Different Data Types<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>student_name = \"Ayesha\"\nroll_no = 12\npercentage = 88.5\npassed = True\n\nprint(student_name)\nprint(roll_no)\nprint(percentage)\nprint(passed)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ayesha\n12\n88.5\nTrue\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3\ufe0f\u20e3 Python Is Case-Sensitive<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"Saddam\"\nName = \"Chandini\"\n\nprint(name)\nprint(Name)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Saddam\nChandini\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4\ufe0f\u20e3 Assigning Multiple Variables at Once<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name, age, city = \"Gousya\", 22, \"Hyderabad\"\n\nprint(name)\nprint(age)\nprint(city)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Gousya\n22\nHyderabad\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5\ufe0f\u20e3 Variable Reassignment<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>person = \"Sameer\"\nprint(person)\n\nperson = \"Ayesha\"\nprint(person)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Sameer\nAyesha\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6\ufe0f\u20e3 Using Variables in Sentences<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"Chandini\"\nage = 24\n\nprint(name, \"is\", age, \"years old\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Chandini is 24 years old\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">7\ufe0f\u20e3 Simple Calculation Using Variables<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>salary = 30000\nbonus = 5000\ntotal_income = salary + bonus\n\nprint(\"Total Income:\", total_income)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Total Income: 35000\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">8\ufe0f\u20e3 Checking Variable Data Types<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"Saddam\"\nage = 28\nheight = 5.7\n\nprint(type(name))\nprint(type(age))\nprint(type(height))\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;class 'str'&gt;\n&lt;class 'int'&gt;\n&lt;class 'float'&gt;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">9\ufe0f\u20e3 Taking Input and Storing in Variables<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = input(\"Enter name: \")\nage = input(\"Enter age: \")\n\nprint(\"Name:\", name)\nprint(\"Age:\", age)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sample Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter name: Sameer\nEnter age: 26\nName: Sameer\nAge: 26\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd1f Input with Type Conversion<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>name = input(\"Enter name: \")\nage = int(input(\"Enter age: \"))\n\nprint(name, \"will be\", age + 1, \"next year\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sample Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter name: Ayesha\nEnter age: 23\nAyesha will be 24 next year\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1\ufe0f\u20e3 Creating Variables Output 2\ufe0f\u20e3 Variables with Different Data Types Output 3\ufe0f\u20e3 Python Is Case-Sensitive Output 4\ufe0f\u20e3 Assigning Multiple Variables at Once Output 5\ufe0f\u20e3 Variable Reassignment Output 6\ufe0f\u20e3 Using Variables in Sentences Output 7\ufe0f\u20e3 Simple Calculation Using Variables Output 8\ufe0f\u20e3 Checking Variable Data Types Output 9\ufe0f\u20e3 Taking Input and Storing in Variables Sample Output \ud83d\udd1f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,1],"tags":[],"class_list":["post-317","post","type-post","status-publish","format-standard","hentry","category-python-easy-course-examples","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317"}],"version-history":[{"count":3,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions\/342"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}