{"id":64247,"date":"2022-07-30T08:18:50","date_gmt":"2022-07-30T08:18:50","guid":{"rendered":"https:\/\/itsourcecode.com\/?p=64247"},"modified":"2023-10-26T03:17:03","modified_gmt":"2023-10-26T03:17:03","slug":"python-basic-syntax","status":"publish","type":"post","link":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/","title":{"rendered":"Python Basic Syntax With Examples And PDF"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>What is basic syntax in Python?<\/strong><\/h2>\n\n\n\n<p>The<strong> basic syntax in Python <\/strong>refers to the set of rules and structures that govern how you write and format code in the Python programming language.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>There are two different types of modes of programming in Python:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Interactive Mode Programming<\/strong><\/li>\n\n\n\n<li><strong>Script Mode Programming<\/strong><\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-interactive-mode-programming\"><strong>1. Interactive Mode Programming<\/strong><\/h3>\n\n\n\n<p><strong>Interactive mode<\/strong> is a command-line shell that <strong>provides an instant response for each statement<\/strong> while executing previously issued commands in active memory.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example\"><strong>Example:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># Python Interactive Mode Programming\n&gt;&gt;&gt; print (\"Hello, Python!\");<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-output\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"># Result when you run the command\nHello, Python!<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-script-mode-programming\"><strong>Script Mode Programming<\/strong><\/h3>\n\n\n\n<p>The <strong>Script Mode Programming<\/strong>, the <strong>Python code is written into a file<\/strong>. The Python interpreter reads the file, then runs it, and gives the desired result.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-0\"><strong>Example:<\/strong><\/h4>\n\n\n\n<p class=\"tw-highlight-padding\">For example, let&#8217;s write a straightforward Python application in a script. In the <strong>test.py<\/strong> file that you have created, type in the following source code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Inside the <em>test.py <\/em>file\nprint (\"Python is FUN!\")<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"tw-highlight-padding\">We&nbsp;assume&nbsp;that&nbsp;the&nbsp;PATH&nbsp;variable&nbsp;contains&nbsp;the&nbsp;<strong>Python&nbsp;interpreter<\/strong>. Now,&nbsp;try&nbsp;running&nbsp;this&nbsp;program&nbsp;this&nbsp;way:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># command prompt or shell - running a Python\nC:\\Python Tutorial&gt;py test.py<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-output-0\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\"># Result when you run the command\nPytho is FUN!<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>In order for you to test your&nbsp;<strong>Python code<\/strong>&nbsp;provided in this lesson, you must test the code on your code editor like&nbsp;<strong>PyCharm<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>But if you wish to run this code online, we also have an&nbsp;<strong><a href=\"https:\/\/itsourcecode.com\/python-compiler\/\">Online Compiler in Python<\/a><\/strong>&nbsp;for you to test your&nbsp;<strong>Python code<\/strong>&nbsp;for free.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Now, here are some key elements of the basic syntax for Python:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-identifiers\"><strong>Python Identifiers<\/strong><\/h2>\n\n\n\n<p>An<strong> identifier in Python<\/strong> is a name that can be used to point to a variable, function, class, module, or other objects.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Here are some rules for naming <strong>Python identifiers:<\/strong><\/p>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>You are not allowed to use reserved\u00a0<strong>keywords<\/strong> or else it will throw\u00a0<mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">SyntaxError<\/mark><strong>.<\/strong><\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>You can&#8217;t name an identifier using numbers only.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>You can&#8217;t start an identifier name with a number.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>The first letter of a class name is always <strong>capitalized<\/strong>. All the other identifiers&nbsp;start with a small letter.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>Identifiers are <strong>case-sensitive<\/strong>, <mark style=\"background-color:var(--base-3);color:#fe0202\" class=\"has-inline-color\"><code>\"<\/code>abc<code>\"<\/code><\/mark> and <mark style=\"background-color:var(--base-3);color:#f90707\" class=\"has-inline-color\"><code>\"<\/code>ABC<code>\"<\/code><\/mark> are different identifiers.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>If an identifier starts with a single underscore, it means that it is a private identifier.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>When an identifier starts with two underscores, it means that it is very private.<\/li>\n<\/ul>\n\n\n\n<ul class=\"tw-highlight-padding wp-block-list\">\n<li>If the end of the identifier also has two underscores, it is a language-defined special name.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-keywords\"><strong>Python Keywords<\/strong><\/h2>\n\n\n\n<p>The <strong>Python keywords<\/strong> are reserved words, which means you can&#8217;t use them as names for constants, variables, or anything else. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>There are no capital letters in any of the Python keywords.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>False<\/td><td>class<\/td><td>finally<\/td><td>is<\/td><td>return<\/td><\/tr><tr><td>None<\/td><td>continue<\/td><td>for<\/td><td>lambda<\/td><td>try<\/td><\/tr><tr><td>True<\/td><td>def<\/td><td>from<\/td><td>nonlocal<\/td><td>while<\/td><\/tr><tr><td>and<\/td><td>del<\/td><td>global<\/td><td>not<\/td><td>with<\/td><\/tr><tr><td>as<\/td><td>elif<\/td><td>if<\/td><td>or<\/td><td>yield<\/td><\/tr><tr><td>assert<\/td><td>else<\/td><td>import<\/td><td>pass<\/td><td><\/td><\/tr><tr><td>break<\/td><td>except<\/td><td>in<\/td><td>raise<\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-lines-and-indentations\"><strong>Lines and Indentations<\/strong><\/h2>\n\n\n\n<p>The <strong>Lines and Indentations<\/strong> are <strong>white spaces in code lines<\/strong>. Python&#8217;s indentation is important, while indentation in other programming languages is just used to improve readability.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The number of spaces in the <strong>indentation <\/strong>can vary, but all of the statements in a block must have the same number of spaces in the indentation.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-1\"><strong>Example:<\/strong><\/h3>\n\n\n\n<p>Let&#8217;s look at a simple example to see how the indentation works.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def sample_function():\n    print(\"Hello, Python!\")\n    if True:\n        print(\"Hi\")\n    else:\n        print(\"Bye!\")\n\nprint(\"Python is Fun!\")<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>We&#8217;re not going to talk about the code and what it does. Instead, let&#8217;s look at the different levels of indentation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Functions\ndef sample_function():<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-quotation-in-python\"><strong>Quotation in Python<\/strong><\/h2>\n\n\n\n<p>In <strong>Python<\/strong>, string objects are made with <strong>quotation marks<\/strong>. Python can read strings with <strong>one, two, or three sets of quotes<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Python supports three kinds of quotation marks:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Single (&#8216;)<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Double (&#8220;)<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Triple (&#8221;&#8217; or &#8220;&#8221;&#8221;)<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>They let the string go across more than one line. For instance, the following are all legal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>word = 'word'\nsentence = \"This is a sentence.\"\nparagraph = \"\"\"This is a paragraph. It is\nmade up of multiple lines and sentences.\"\"\"<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>The triple quotation marks have already been used to create a multi-line comment in the comments section. <\/p>\n\n\n\n<p>In Python, strings are declared with single and double quotes.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-newline-character-in-python\"><strong>Newline Character in Python<\/strong><\/h2>\n\n\n\n<p>The<strong> newline character in Python<\/strong> is the n character which is used to start a new line. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>This character tells the computer that the end of a line has been reached, and any more characters will be printed on a new line.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-2\"><strong>Example:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sample1 = \"This is an example\\nThis is the sentence with new line.\"\nprint(sample1)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-output-1\"><strong>Output:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\">This is an example\nThis is the sentence with new line.<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-comments-in-python\"><strong>Comments in Python<\/strong><\/h2>\n\n\n\n<p class=\"tw-highlight-padding\">A line of text that occurs in a program but is not executed by the program is referred to as a <strong>comment in Python<\/strong>. Comments in Python start with the <mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff0000\" class=\"has-inline-color\"># <\/mark>sign.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"tw-highlight-padding\">They can go at the start of a line, after a blank space, or after some code. If a string literal has the <mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff0000\" class=\"has-inline-color\"># <\/mark>character, it is part of the string.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-3\"><strong>Example:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># First comment\nprint (\"Python is Fun!\") # Second comment<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>This leads to the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted tw-rounded\">Python is Fun!<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>You can comment on more than one line in the ways below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># First comment\n# Second comment\n# Third comment\n# Fourth comment<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>The Python interpreter also doesn&#8217;t care about the following triple-quoted string, which can be used as a multiline comment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'''\nThis is a multiline\ncomment.\n'''<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-blank-lines\"><strong>Using Blank Lines<\/strong><\/h2>\n\n\n\n<p class=\"tw-highlight-padding\">A <strong>line <\/strong>that only has whitespace on it, possibly with a comment, is called a <mark style=\"background-color:var(--base-3);color:#fe0000\" class=\"has-inline-color\">&#8220;blank line&#8221;<\/mark>, and Python doesn&#8217;t care about it at all.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>To end a multiline statement in an interactive interpreter session, you must type an empty line.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-multiple-statements-on-a-single-line\"><strong>Multiple Statements on a Single Line<\/strong><\/h2>\n\n\n\n<p class=\"tw-highlight-padding\">To write <strong>multiple statements in a single line in Python<\/strong>, you have to use the <strong>semicolon <\/strong>(<code><mark style=\"background-color:var(--base);color:#fe0000\" class=\"has-inline-color\">;<\/mark><\/code>). <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>A semicolon lets you put more than one statement on one line, as long as none of the statements start a new code block.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-4\"><strong>Example:<\/strong><\/h3>\n\n\n\n<p class=\"tw-highlight-padding\">Here is an example of how to use a semicolon:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># using semicolon\nimport sys; x = 'foo'; sys.stdout.write(x + '\\n')<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-command-line-arguments\"><strong>Command Line Arguments<\/strong><\/h2>\n\n\n\n<p><strong>Command Line Arguments<\/strong> refer to the arguments given after the program&#8217;s name in the command line shell of the operating system. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>For example, if we wrote a program to read a CSV file, entering a CSV file from the command line would make our program work for any CSV file, making it generic.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>So, how do we pass arguments on the command line in Python?<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It&#8217;s simple. You need to run the Python script from the terminal the way we talked about at the beginning of the article and then add the inputs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># argument sample\npython test_file.py arg1 arg2 \u2026 arg N<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"tw-highlight-padding\">Here, <strong>test_file.py<\/strong> is the name of the script, and <mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">arg1<\/mark><em> <\/em>through <mark style=\"background-color:var(--base-3);color:#ff0000\" class=\"has-inline-color\">argN<\/mark><em> <\/em>are the <mark style=\"background-color:var(--base);color:#ff0000\" class=\"has-inline-color\">N<\/mark><em> <\/em>arguments that must be given on the command line.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>You must be wondering how one could read the command line arguments. The most common way is to use the sys module.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-download-python-basic-syntax-pdf\"><strong>Download Python Basic Syntax PDF<\/strong><\/h2>\n\n\n\n<p>You can download the Python Basic Syntax PDF file by clicking the download button below:<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-accent-background-color has-background wp-element-button\" href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/07\/Python-Basic-Syntax-with-PDF.pdf\" style=\"border-radius:100px\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Download PDF<\/strong><\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-summary\"><strong>Summary<\/strong><\/h2>\n\n\n\n<p>In Python syntax, we covered interactive and script modes in this tutorial. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>We talked about identifiers, keywords, lines and indentation, multi-line statements, quotes, comments, blank lines, user input, and command-line parameters.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>I hope that this&nbsp;<strong>Python Basic Syntax<\/strong>&nbsp;helps you understand the basics of Python and how to write and execute a Python program.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<div class=\"wp-block-columns tw-mb-0 tw-stretched-blocks tw-justify-center tw-gutter-no tw-cols-stack-sm tw-cols-card tw-cols-card-border tw-stretched-link is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-buttons tw-mb-0 tw-mt-0 is-content-justification-left is-nowrap is-layout-flex wp-container-core-buttons-is-layout-558b13e7 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-base-3-background-color has-background wp-element-button\" href=\"https:\/\/itsourcecode.com\/python-tutorial\/how-to-setup-python-environment-in-windows-10\/\" style=\"border-radius:0px\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">\u2770\u2770<\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\"><strong>Previous<\/strong><\/mark><\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-left tw-mt-0 tw-mb-0 tw-link-hover-underline\" style=\"font-style:normal;font-weight:100\">Python Environment Setup<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column tw-mt-0 tw-mb-0 is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-buttons tw-mb-0 tw-mt-0 is-content-justification-right is-nowrap is-layout-flex wp-container-core-buttons-is-layout-5054138e wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-base-3-background-color has-background wp-element-button\" href=\"https:\/\/itsourcecode.com\/python-tutorial\/python-variable-types\/\" style=\"border-radius:0px\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\"><strong>Next <\/strong>\u2771\u2771<\/mark><\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-right tw-mt-0 tw-mb-0 tw-link-hover-underline\" style=\"font-style:normal;font-weight:100\">Python Variable Types<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is basic syntax in Python? The basic syntax in Python refers to the set of rules and structures that govern how you write and format code in the Python &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Basic Syntax With Examples And PDF\" class=\"read-more button\" href=\"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#more-64247\" aria-label=\"Read more about Python Basic Syntax With Examples And PDF\">Read more<\/a><\/p>\n","protected":false},"author":1373,"featured_media":64691,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61036],"tags":[81311,93886,81305,93887,93885],"class_list":["post-64247","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorial","tag-basic-syntax-in-python","tag-basic-syntax-in-python-pdf","tag-python-basic-syntax","tag-python-basic-syntax-pdf-download","tag-python-basic-syntax-with-pdf","resize-featured-image"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Basic Syntax With Examples And PDF<\/title>\n<meta name=\"description\" content=\"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Basic Syntax With Examples And PDF\" \/>\n<meta property=\"og:description\" content=\"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"Itsourcecode.com\" \/>\n<meta property=\"article:author\" content=\"www.facebook.com\/unguardable7\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-30T08:18:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-26T03:17:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prince Ly Cesar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/www.twitter.com\/unguardable0729\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prince Ly Cesar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/\"},\"author\":{\"name\":\"Prince Ly Cesar\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/8d6ff1c108160ddbd60ff17cbb9f626b\"},\"headline\":\"Python Basic Syntax With Examples And PDF\",\"datePublished\":\"2022-07-30T08:18:50+00:00\",\"dateModified\":\"2023-10-26T03:17:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/\"},\"wordCount\":1107,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Python-Basic-Syntax.png\",\"keywords\":[\"basic syntax in python\",\"basic syntax in python pdf\",\"python basic syntax\",\"python basic syntax pdf download\",\"Python Basic Syntax with PDF\"],\"articleSection\":[\"Python Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/\",\"name\":\"Python Basic Syntax With Examples And PDF\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Python-Basic-Syntax.png\",\"datePublished\":\"2022-07-30T08:18:50+00:00\",\"dateModified\":\"2023-10-26T03:17:03+00:00\",\"description\":\"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#primaryimage\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Python-Basic-Syntax.png\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Python-Basic-Syntax.png\",\"width\":1460,\"height\":900,\"caption\":\"Python Basic Syntax Definition and Examples\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/python-tutorial\\\/python-basic-syntax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/itsourcecode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Basic Syntax With Examples And PDF\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/\",\"name\":\"Itsourcecode.com\",\"description\":\"Partner In Your Coding Journey!\",\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/itsourcecode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\",\"name\":\"itsourcecode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"width\":409,\"height\":409,\"caption\":\"itsourcecode\"},\"logo\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\"},\"description\":\"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!\",\"sameAs\":[\"https:\\\/\\\/itsourcecode.com\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/8d6ff1c108160ddbd60ff17cbb9f626b\",\"name\":\"Prince Ly Cesar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215\",\"caption\":\"Prince Ly Cesar\"},\"description\":\"Hi there! I'm Prince Ly Cesar a Student in Carlos Hilado Memorial State College - Binalbagan Campus and a Graphic Designer, Programmer &amp; Writer in IT SourceCode\",\"sameAs\":[\"https:\\\/\\\/activadorkeys.com\\\/\",\"www.facebook.com\\\/unguardable7\",\"http:\\\/\\\/www.instagram.com\\\/prnclycsr\\\/\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/www.twitter.com\\\/unguardable0729\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCF0BIqB5tpnCmwvYQCHucmw?view_as=subscriber\"],\"gender\":\"male\",\"knowsAbout\":[\"Graphic Designing\"],\"knowsLanguage\":[\"English\",\"Tagalog\"],\"jobTitle\":\"Graphic Designer\",\"worksFor\":\"IT SourceCode\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/author\\\/unguardable\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Basic Syntax With Examples And PDF","description":"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics","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:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/","og_locale":"en_US","og_type":"article","og_title":"Python Basic Syntax With Examples And PDF","og_description":"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics","og_url":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/","og_site_name":"Itsourcecode.com","article_author":"www.facebook.com\/unguardable7","article_published_time":"2022-07-30T08:18:50+00:00","article_modified_time":"2023-10-26T03:17:03+00:00","og_image":[{"width":1460,"height":900,"url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png","type":"image\/png"}],"author":"Prince Ly Cesar","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/www.twitter.com\/unguardable0729","twitter_misc":{"Written by":"Prince Ly Cesar","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#article","isPartOf":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/"},"author":{"name":"Prince Ly Cesar","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/8d6ff1c108160ddbd60ff17cbb9f626b"},"headline":"Python Basic Syntax With Examples And PDF","datePublished":"2022-07-30T08:18:50+00:00","dateModified":"2023-10-26T03:17:03+00:00","mainEntityOfPage":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/"},"wordCount":1107,"commentCount":0,"publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"image":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png","keywords":["basic syntax in python","basic syntax in python pdf","python basic syntax","python basic syntax pdf download","Python Basic Syntax with PDF"],"articleSection":["Python Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/","url":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/","name":"Python Basic Syntax With Examples And PDF","isPartOf":{"@id":"https:\/\/itsourcecode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#primaryimage"},"image":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png","datePublished":"2022-07-30T08:18:50+00:00","dateModified":"2023-10-26T03:17:03+00:00","description":"Basic Syntax in Python is one of the fundamental criteria for writing code in Python. We covered different topics for you to learn the basics","breadcrumb":{"@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#primaryimage","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Python-Basic-Syntax.png","width":1460,"height":900,"caption":"Python Basic Syntax Definition and Examples"},{"@type":"BreadcrumbList","@id":"https:\/\/itsourcecode.com\/python-tutorial\/python-basic-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itsourcecode.com\/"},{"@type":"ListItem","position":2,"name":"Python Basic Syntax With Examples And PDF"}]},{"@type":"WebSite","@id":"https:\/\/itsourcecode.com\/#website","url":"https:\/\/itsourcecode.com\/","name":"Itsourcecode.com","description":"Partner In Your Coding Journey!","publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itsourcecode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc","name":"itsourcecode","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","width":409,"height":409,"caption":"itsourcecode"},"logo":{"@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg"},"description":"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!","sameAs":["https:\/\/itsourcecode.com\/"]},{"@type":"Person","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/8d6ff1c108160ddbd60ff17cbb9f626b","name":"Prince Ly Cesar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","url":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/8fc9fa13530f18706fe0948f4673fae8.jpg?ver=1776478215","caption":"Prince Ly Cesar"},"description":"Hi there! I'm Prince Ly Cesar a Student in Carlos Hilado Memorial State College - Binalbagan Campus and a Graphic Designer, Programmer &amp; Writer in IT SourceCode","sameAs":["https:\/\/activadorkeys.com\/","www.facebook.com\/unguardable7","http:\/\/www.instagram.com\/prnclycsr\/","https:\/\/x.com\/http:\/\/www.twitter.com\/unguardable0729","https:\/\/www.youtube.com\/channel\/UCF0BIqB5tpnCmwvYQCHucmw?view_as=subscriber"],"gender":"male","knowsAbout":["Graphic Designing"],"knowsLanguage":["English","Tagalog"],"jobTitle":"Graphic Designer","worksFor":"IT SourceCode","url":"https:\/\/itsourcecode.com\/author\/unguardable\/"}]}},"_links":{"self":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/64247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/users\/1373"}],"replies":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/comments?post=64247"}],"version-history":[{"count":52,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/64247\/revisions"}],"predecessor-version":[{"id":119345,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/64247\/revisions\/119345"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media\/64691"}],"wp:attachment":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media?parent=64247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/categories?post=64247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/tags?post=64247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}