{"id":24239,"date":"2023-03-17T20:38:59","date_gmt":"2023-03-17T15:08:59","guid":{"rendered":"https:\/\/tocxten.com\/?page_id=24239"},"modified":"2023-04-04T08:18:04","modified_gmt":"2023-04-04T02:48:04","slug":"1-python-basics","status":"publish","type":"page","link":"https:\/\/tocxten.com\/index.php\/1-python-basics\/","title":{"rendered":"1. Python Basics"},"content":{"rendered":"\n<p class=\"has-large-font-size\"><strong>Syllabus : <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Python Basics<\/strong>: Introduction,  Entering Expressions into the Interactive Shell, The Integer, Floating-Point, and String Data Types, String Concatenation and Replication, Storing Values in Variables, Your First Program, Dissecting Your Program.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.1 Introduction<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language.&nbsp; It was created by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Guido_van_Rossum\">Guido van Rossum<\/a> during 1985 &#8211; 1990. Python is named after a TV Show called \u2018<a href=\"https:\/\/towardsdatascience.com\/why-is-python-called-python-e3eb451f73a9\">Monty Python\u2019s Flying Circus<\/a>\u2019 and not after Python-the snake. <strong>Some of the Features that Makes Python more popular are<\/strong>:<\/p>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li>Python is Simple and Easy to learn and code.<\/li><li>Python is Free and Open Source. It is freely available at the https:\/\/www.python.org\/ . Python source code is also available to the public, one can download it, use it, and share it.<\/li><li>Python is High Level Language and supports both Procedure oriented and Object-Oriented Language concepts along with dynamic memory management.<\/li><li>Python is portable. Python code can be run on any platforms like Linux, Unix, Mac and Windows.<\/li><li>Python is extensible and integrated. Python code can be extended and integrated with among other languages like C, C++, Java, etc.<\/li><li>Python is an interpreted language. Python code is executed line by line at a time and there is no need to compile, which makes debugging easier.<\/li><li>Python has rich set of libraries for data analytics, machine learning, artificial intelligence, deep learning, mathematical computation, web app development, mobile app development, testing, etc.<\/li><li>Python is a dynamically typed language. Here the data type for variable is decided at run time. As a result, there is no need to specify the type of variable.<\/li><\/ul>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.2 Why One Should Learn Python Program?<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Python Programming is a fun, creative and rewarding activity. Python is one of the most widely used programming language across the world for developing software applications. It is named as one of top picked programming languages of most of the universities and industries. There are several reasons why learning Python programming can be beneficial, including:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Versatility: <\/strong>Python is a versatile language that can be used for a variety of tasks, such as web development, data analysis, scientific computing, machine learning, and artificial intelligence. It is used by companies such as Google, Instagram, Spotify, and Dropbox.<\/li><li><strong>Easy to learn: <\/strong>Python has a simple syntax that is easy to read and write, making it a great language for beginners. It also has a large standard library with pre-built modules and functions that can be used to perform various tasks, reducing the amount of code that needs to be written.<\/li><li><strong>Large community: <\/strong>Python has a large community of developers who contribute to open-source projects, create libraries and frameworks, and offer support and resources for learning. This community provides a wealth of knowledge and resources that can help beginners get started with programming and advanced developers solve complex problems.<\/li><li><strong>High demand: <\/strong>Python is one of the most popular programming languages in the world, and there is a high demand for developers who know how to use it. Learning Python can open up many job opportunities in various industries, such as tech, finance, healthcare, and more.<\/li><li><strong>Future-proof: <\/strong>Python has been around for over 30 years and continues to evolve and improve. It is expected to remain relevant in the future and is likely to continue to be used for a wide range of applications.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Overall, learning Python programming can be a valuable skill that can lead to many opportunities and benefits in both personal and professional life.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Reference Video : <a href=\"https:\/\/youtu.be\/0_n9CihzJLo\">Top 10 Reasons To Learn Python<\/a><\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Steps to Learn Python Programming Language : <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Here are some general steps you can follow to learn the Python programming language:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Learn the basics:<\/strong> Start by learning the fundamental concepts of Python programming, including data types, variables, operators, control structures, functions, and modules. There are many online resources and books available to help you learn the basics of Python.<\/li><li><strong>Practice writing code:<\/strong> Once you have a basic understanding of the concepts, start practicing writing code in Python. Start with simple programs, such as a program that prints &#8220;Hello, World!&#8221; to the console. As you become more comfortable with the language, try writing more complex programs.<\/li><li><strong>Learn from examples: <\/strong>There are many online resources where you can find examples of Python code, including tutorials, blog posts, and open-source projects. Look for examples that solve problems similar to what you want to achieve and try to understand how they work.<\/li><li><strong>Join a community:<\/strong> Python has a large and active community of programmers who are eager to help others learn. Join an online programming community, attend coding meetups or workshops, or find a mentor who can help you improve your coding skills.<\/li><li><strong>Practice regularly:<\/strong> Like any skill, learning to program takes practice. Set aside regular time to practice writing code and experimenting with different techniques. The more you practice, the better you will become.<\/li><li><strong>Build projects: <\/strong>Once you have a good grasp of the fundamentals of Python programming, start building projects. Choose projects that interest you, such as building a web application, analyzing data, or automating tasks. Building projects will help you apply what you&#8217;ve learned and gain practical experience.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Learning  program takes time and effort. Be patient with yourself, don&#8217;t be afraid to make mistakes, and keep practicing. With persistence and dedication, you can become a skilled Python programmer.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>General Steps to teach Python Programming Language <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Here are some general steps you can follow to teach Python programming language:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Introduce the basics:<\/strong> Start by introducing the fundamental concepts of Python programming, including data types, variables, operators, control structures, functions, and modules. Provide examples and exercises to help students understand the concepts.<\/li><li><strong>Use interactive learning tools<\/strong>: Use interactive learning tools, such as coding challenges, quizzes, and games, to help students practice writing Python code and reinforce their learning.<\/li><li><strong>Provide real-world examples:<\/strong> Use examples that relate to real-world problems or scenarios to help students understand how Python can be used in practical applications. This can help keep students engaged and motivated.<\/li><li><strong>Encourage collaboration:<\/strong> Encourage students to work together on programming projects, as this can help them learn from each other and develop problem-solving skills.<\/li><li><strong>Provide feedback: <\/strong>Provide feedback on students&#8217; code and offer suggestions for improvement. This can help students learn from their mistakes and improve their coding skills.<\/li><li><strong>Supplement with online resources:<\/strong> There are many online resources available to help students learn Python programming, including tutorials, videos, and interactive coding environments. Use these resources to supplement your own teaching and provide students with additional opportunities to practice and learn.<\/li><li><strong>Assign projects<\/strong>: Assign projects that challenge students to apply what they&#8217;ve learned in creative and practical ways. This can help students build confidence and demonstrate their understanding of the material.<\/li><li><strong>Assess student progress<\/strong>: Regularly assess student progress to ensure they are understanding the material and making progress. Use quizzes, tests, or project-based assessments to evaluate student understanding and provide feedback.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Teaching Python programming requires<strong> patience, persistence, and dedication<\/strong>. Be prepared to adjust your teaching methods based on the needs and progress of your students, and always be willing to learn and improve your own teaching skills.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>Applications Of Python : <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Python is a versatile programming language that can be used in many different applications. Here are some of the most common uses of Python:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Web development<\/strong>: Python is used to develop web applications, such as Flask and Django. It is a popular choice for web development because of its simplicity and versatility.<\/li><li><strong>Data analysis<\/strong>: Python has many libraries for data analysis, such as NumPy, Pandas, and Matplotlib. These libraries can be used to analyze and visualize data.<\/li><li><strong>Machine learning: <\/strong>Python is used for machine learning and artificial intelligence applications, such as TensorFlow and Keras. These libraries can be used to build and train machine learning models.<\/li><li><strong>Automation:<\/strong> Python is used to automate tasks, such as web scraping and file handling. It can also be used for system administration tasks, such as server management and network automation.<\/li><li><strong>Game development: <\/strong>Python is used to develop games, such as Pygame and PyOpenGL. These libraries can be used to create 2D and 3D games.<\/li><li><strong>Desktop applications:<\/strong> Python is used to create desktop applications, such as music players and text editors. The PyQt and Tkinter libraries can be used to create graphical user interfaces (GUIs).<\/li><li><strong>Scientific computing: <\/strong>Python is used in scientific computing applications, such as computational biology and physics simulations. The SciPy and NumPy libraries can be used for numerical computation and scientific data analysis.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Overall, Python is a versatile language that can be used in many different applications. Its ease of use, large library of modules and functions, and community support make it an excellent choice for many different types of projects.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.3 Zen of Python<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">The Zen of Python is a collection of guiding principles for writing computer programs in the Python language. It was written by Tim Peters, a long-time contributor to the Python community. The Zen of Python can be accessed by typing &#8220;import this&#8221; in a Python interpreter or code editor.The Zen of Python is made up of 19 aphorisms that encourage simplicity, readability, and practicality in programming. Simple Python code that displays the Zen of Python is as follows:<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Source Code : <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import this \nprint this <\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Output : <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Beautiful is better than ugly.\nExplicit is better than implicit.\nSimple is better than complex.\nComplex is better than complicated.\nFlat is better than nested.\nSparse is better than dense.\nReadability counts.\nSpecial cases aren't special enough to break the rules.\nAlthough practicality beats purity.\nErrors should never pass silently.\nUnless explicitly silenced.\nIn the face of ambiguity, refuse the temptation to guess.\nThere should be one-- and preferably only one --obvious way to do it.\nAlthough that way may not be obvious at first unless you're Dutch.\nNow is better than never.\nAlthough never is often better than right now.\nIf the implementation is hard to explain, it's a bad idea.\nIf the implementation is easy to explain, it may be a good idea.\nNamespaces are one honking great idea -- let's do more of those!<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Building Blocks : <\/strong><\/p>\n\n\n\n<p>In the context of programming languages, building blocks refer to the fundamental concepts, components, or elements that form the foundation of the language. These building blocks are used to create more complex programs and applications.<\/p>\n\n\n\n<p>In programming, building blocks are similar to the building blocks used in construction. Just as a construction worker uses bricks, concrete, and steel to build a building, a programmer uses building blocks like variables, data types, operators, and control structures to build software applications.<\/p>\n\n\n\n<p>The concept of building blocks is important because it allows programmers to break down complex problems into smaller, more manageable pieces. By understanding the building blocks of a programming language, programmers can use them to create solutions to specific problems and build more complex software applications.<\/p>\n\n\n\n<p>In summary, building blocks are the basic components of a programming language that are used to create programs and applications. Understanding these building blocks is essential for learning and writing programs in any programming language.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Building Blocks of Python <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">The building blocks of Python include:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Variables:<\/strong> Variables are used to store values in Python. They can hold different types of data such as numbers, strings, or lists.<\/li><li><strong>Data Types:<\/strong> Data types determine the type of data that can be stored in a variable. Common data types in Python include integers, floating-point numbers, strings, lists, and dictionaries.<\/li><li><strong>Operators:<\/strong> Operators are used to perform mathematical or logical operations on data. Examples include arithmetic operators like +, -, *, and \/, and comparison operators like ==, >, and &lt;.<\/li><li><strong>Control Structures: <\/strong>Control structures are used to control the flow of execution in a program. Examples include if-else statements, while loops, and for loops.<\/li><li><strong>Functions: <\/strong>Functions are reusable blocks of code that perform a specific task. They can take input arguments and return output values.<\/li><li><strong>Modules:<\/strong> Modules are pre-written Python code that can be imported into a program to provide additional functionality.<\/li><li><strong>Comments: <\/strong>Comments are used to add notes to Python code that explain what the code is doing. They are ignored by the Python interpreter.<\/li><li><strong>Indentation: <\/strong>Python uses indentation to indicate blocks of code. This means that the indentation level of each line of code is important and must be consistent.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Understanding these building blocks is essential for learning and writing Python programs.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\">1.4 <strong>Installing Python:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Before starting the programming in Python, one should install Python interpreter on the computer. To install python one must download the installation package of the required version from the link\/ULR : <a href=\"https:\/\/www.python.org\/\">https:\/\/www.python.org\/<\/a>. For windows there is a &nbsp;<a href=\"https:\/\/www.python.org\/ftp\/python\/3.7.9\/python-3.7.9-amd64.exe\">Windows x86-64 executable installer<\/a> in both 32 bit and 64 bit versions. Latest python release as on 5<sup>th<\/sup> September 2020 is Python 3.8.5 .<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Here are the steps to install Python on your computer:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li>Go to the official Python website at <a href=\"https:\/\/www.python.org\/\">https:\/\/www.python.org\/<\/a>.<\/li><li>Click on the &#8220;Downloads&#8221; tab at the top of the page.<\/li><li>Scroll down and choose the latest version of Python that is compatible with your operating system. For example, if you&#8217;re using Windows, you may want to download the latest version of Python 3 for Windows.<\/li><li>Click on the installer file to begin the installation process.<\/li><li>Follow the prompts in the installer to complete the installation process. You may be asked to choose a destination folder for Python and select optional features to install.<\/li><li>Once the installation is complete, you should be able to access Python from the command line or through a Python IDE (Integrated Development Environment) like PyCharm or IDLE.<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Illustration <\/strong>: <\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Launch a web browser then navigate to downloads for Windows. Download the Python 3.8.5.<\/strong><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1.png\" alt=\"\" class=\"wp-image-24252\" width=\"671\" height=\"249\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1.png 804w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1-300x111.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1-768x285.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1-760x282.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-1-600x222.png 600w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">2. <strong>When the download completes run the installer<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"287\" height=\"77\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-2.png\" alt=\"\" class=\"wp-image-24256\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">3. <strong>Choose to install Now<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3.png\" alt=\"\" class=\"wp-image-24257\" width=\"651\" height=\"344\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3.png 781w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3-300x159.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3-768x406.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3-760x402.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-3-600x317.png 600w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">4.<strong>After the setup is completely installed you will get Setup was successful message.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4.png\" alt=\"\" class=\"wp-image-24259\" width=\"652\" height=\"404\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4.png 825w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4-300x186.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4-768x476.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4-760x471.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-4-600x372.png 600w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/figure>\n\n\n\n<p><strong>Reference Video : <a href=\"https:\/\/youtu.be\/riL_xn6BKD8\">Introduction to Python IDLE | IDLE Installation and Configuration Tutorial | Edureka<\/a><\/strong><\/p>\n\n\n\n<p><strong>Reference Video Link : <a href=\"https:\/\/youtu.be\/riL_xn6BKD8\">How to install Python 3.10.0 on Windows 10<\/a><\/strong><\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.5 Interacting with Python IDLE (Integrated Development Learning Environment)<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">To write and run Python code interactively one can either use the command line window (Shell) or the IDLE. IDLE is Integrated Development Learning Environment that comes with Python, that can be used to edit, run, browse, and debug a Python program from a single interface.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">1..5.1 <strong>Python Shell<\/strong> <strong>and Python Editor:<\/strong> Python IDLE can started by clicking its icon created on the desktop or menu item on the <strong>START menu -&gt; Python3.8 -&gt; IDLE (Python3.8 32- bit)<\/strong> option as illustrated below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-5.png\" alt=\"\" class=\"wp-image-24269\" width=\"254\" height=\"210\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-5.png 403w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-5-300x248.png 300w\" sizes=\"auto, (max-width: 254px) 100vw, 254px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Python IDLE comprises Python shell <strong>(Interactive mode)<\/strong> and Python Editor (<strong>Script mode<\/strong>).<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Python Shell:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6.png\" alt=\"\" class=\"wp-image-24270\" width=\"549\" height=\"243\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6.png 866w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6-300x133.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6-768x341.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6-760x337.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-6-600x266.png 600w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Python Editor:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-7.png\" alt=\"\" class=\"wp-image-24271\" width=\"552\" height=\"284\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-7.png 749w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-7-300x155.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-7-600x309.png 600w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Python IDLE always starts by default with shell. Python shell shows a header message displaying its version and copyright notice. Soon after the header message, the command prompt (<strong>&gt;&gt;&gt;<\/strong>) followed by blinking cursor gets displayed, indicating its readiness for accepting user Python commands\/instructions \/code. The three greater than symbols are called the prompt or Python Command prompt.&nbsp; Python Shell is an interactive window where we can type in the Python code and see the output in the same window as illustrated below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8.png\" alt=\"\" class=\"wp-image-24274\" width=\"572\" height=\"256\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8.png 974w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8-300x135.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8-768x345.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8-760x342.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-8-600x270.png 600w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>1.5.2<\/strong> <strong>Entering Expressions into the interactive Shell<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">In Python, expression is the most basic kind of programming instruction in the language<strong>. <\/strong>An expression is a combination of <strong><em>values, variables, and operators<\/em><\/strong>.<\/p>\n\n\n\n<p><strong>Examples:<\/strong> 17, x, x+17 ,1+2*2 , X**2, x**2 +y**2<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9.png\" alt=\"\" class=\"wp-image-24275\" width=\"527\" height=\"149\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9.png 974w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9-300x85.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9-768x217.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9-760x215.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-9-600x169.png 600w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.6 Value:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">A value is a letter or a number assigned to a variable or constant. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Example: <\/strong>1, 2 , 33.45 ,&#8221;USN&#8221; and \u201cHello, World!\u201d.  <\/p>\n\n\n\n<p class=\"has-medium-font-size\">Value may be of different types. Types are the data types to which the Values belong. Type may int, float, string, complex number, dictionary, list, sets, boolean values , binary numbers ,etc. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>type(arg)<\/strong> function returns the <strong>data type<\/strong> of the argument as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-10.png\" alt=\"\" class=\"wp-image-24276\" width=\"210\" height=\"160\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-10.png 524w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-10-300x228.png 300w\" sizes=\"auto, (max-width: 210px) 100vw, 210px\" \/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.7 Data types:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Python supports various data types. Here are some of the most commonly used data types in Python along with examples:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li><strong>Numeric Types<\/strong>:<ul><li>int: integers with no fractional part, e.g., 42, -5, 0<\/li><li>float: floating-point numbers with a fractional part, e.g., 3.14, -0.5, 2.0<\/li><li>Complex (complex): complex number with a real and imaginary part z = 2 + 3j,z2 = 1 &#8211; 2j,z3 = 4 + 0j<\/li><\/ul><\/li><li><strong>Boolean Type<\/strong>:<ul><li>bool: represents two values True or False<\/li><\/ul><\/li><li><strong>Sequence Types<\/strong>:<ul><li>str: a sequence of Unicode characters, e.g., &#8220;Hello&#8221;, &#8216;world&#8217;, &#8220;I&#8217;m a string&#8221;<\/li><li>list: an ordered sequence of items, e.g., [1, 2, 3], [&#8216;apple&#8217;, &#8216;banana&#8217;, &#8216;cherry&#8217;]<\/li><li>tuple: an ordered, immutable sequence of items, e.g., (1, 2, 3), (&#8216;apple&#8217;, &#8216;banana&#8217;, &#8216;cherry&#8217;)<\/li><\/ul><\/li><li><strong>Set Types<\/strong>:<ul><li>set: an unordered collection of unique items, e.g., {1, 2, 3}, {&#8216;apple&#8217;, &#8216;banana&#8217;, &#8216;cherry&#8217;}<\/li><li>Frozen Set (frozenset): fruits = frozenset([&#8220;apple&#8221;, &#8220;banana&#8221;, &#8220;cherry&#8221;]) <\/li><\/ul><\/li><li><strong>Mapping Type<\/strong>:<ul><li>dict: a collection of key-value pairs, e.g., {&#8216;name&#8217;: &#8216;John&#8217;, &#8216;age&#8217;: 25}<\/li><\/ul><\/li><li><strong>Other Types<\/strong>:<ul><li>bytes: a sequence of bytes, e.g., b&#8217;hello&#8217;<\/li><li>bytearray: a mutable sequence of bytes, e.g., bytearray(b&#8217;hello&#8217;)<\/li><li>Memoryview (memoryview)<\/li><li>NoneType: represents the absence of a value, e.g., None<\/li><\/ul><\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">These are the built-in data types in Python. There are also many other data types that are available through Python libraries or can be created by the programmer.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.8 Variables <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">In Python, a variable is a named reference to a value that is stored in memory. A variable is created when a value is assigned to it using the assignment operator <code>=<\/code>. <\/p>\n\n\n\n<p class=\"has-medium-font-size\">Examples : <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Message = \u2018Python Programming \u2018,&nbsp;\np =1000, t= 2, r=3.142,\nSi = p*t*r\/100,\npi = 3.1415926535897931,\narea_of _circle = pi*r*r.<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">Here are some rules for naming Python variables:<\/p>\n\n\n\n<ol class=\"has-medium-font-size wp-block-list\"><li>Variable names should begin with a letter (a-z or A-Z) or an underscore (_). They cannot begin with a number.<\/li><li>Variable names can only contain letters, numbers, and underscores. Special characters such as !, @, #, etc. are not allowed.<\/li><li>Variable names are case-sensitive, meaning &#8220;myVar&#8221; and &#8220;myvar&#8221; are considered as two different variables.<\/li><li>Variable names should be descriptive, and they should reflect the purpose of the variable. For example, if a variable stores a person&#8217;s age, you could name it &#8220;age.&#8221;<\/li><li>Avoid using reserved keywords as variable names. Reserved keywords are words that have a special meaning in Python, such as &#8220;if,&#8221; &#8220;else,&#8221; &#8220;while,&#8221; etc.<\/li><li>Use lowercase letters for variable names, unless you have a good reason to use uppercase letters.<\/li><li>If a variable name contains multiple words, use underscores to separate them. For example, if a variable stores a person&#8217;s full name, you could name it &#8220;full_name.&#8221;<\/li><\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Following above rules can make your code more readable and understandable for other developers.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Table:<\/strong>&nbsp;Valid Variable Names and Invalid Variable Names<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Valid Variable Names<\/strong><\/td><td><strong>Invalid Variable Names<\/strong><\/td><\/tr><tr><td><strong>python12<\/strong><\/td><td><strong>current- account<\/strong>&nbsp;(hyphens are not allowed)<\/td><\/tr><tr><td><strong>Simple<\/strong><\/td><td><strong>savings&nbsp; account<\/strong>&nbsp;(spaces are not allowed)<\/td><\/tr><tr><td><strong>interest_year<\/strong><\/td><td><strong>4freinds<\/strong>&nbsp;(can\u2019t begin with a number)<\/td><\/tr><tr><td><strong>_rate_of_interest<\/strong><\/td><td><strong>19\/08\/2004&nbsp;<\/strong>(can\u2019t begin with a number special characters like \/ are not allowed)<\/td><\/tr><tr><td><strong>_spam<\/strong><\/td><td><strong>10April_$&nbsp;<\/strong>(cannot begin with a number and special characters like $ are not allowed)<\/td><\/tr><tr><td><strong>HAM<\/strong><\/td><td><strong>Principle#@<\/strong>&nbsp;( special characters like&nbsp; # and @ are not allowed)<\/td><\/tr><tr><td><strong>account1234<\/strong><\/td><td><strong>\u2018bear\u2019&nbsp;<\/strong>( special characters like&nbsp; \u2018 is not allowed)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Note:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Variable names are case-sensitive, meaning that&nbsp;<strong>velocity, VELOCITY, Velocity<\/strong>&nbsp;and&nbsp;<strong>VeloCity<\/strong>&nbsp;are four different variables. It is a Python convention to start your variables with a lowercase letter.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.10&nbsp;Storing Values in a Variables :<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Values can be stored in a variable using Assignment statement. An assignment statement consists of a variable name , an equal sign and the value to be stored .<\/p>\n\n\n\n<p><strong>Example :<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-11.png\" alt=\"\" class=\"wp-image-24289\" width=\"191\" height=\"158\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">A variable&nbsp;&nbsp;<strong>ham<\/strong>&nbsp;is initialized (or created ) the first time a value is stored in it. After that one can use it in expression with other variables and values like&nbsp;<strong><em>ham + spam<\/em><\/strong>. When a variable is assigned a new value, old value gets erased or forgotten. This is called overwriting. Following code illustrates the overwriting of string<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-12.png\" alt=\"\" class=\"wp-image-24291\" width=\"153\" height=\"118\"\/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.11 Sample Program:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">To read and print your name and age<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"643\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-13.png\" alt=\"\" class=\"wp-image-24294\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-13.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-13-300x251.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-13-760x636.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-13-600x502.png 600w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.12 Dissecting the Sample Program&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Sample program comprises executable statements containing comments and built in functions like&nbsp;<strong>print () , input () , len() , int() and str()<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Comments:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Comments are readable explanation or descriptions that help programmers better understand the intent and functionality of the source code. Comments are completely ignored by interpreter.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Advantages of Using Comments:<\/strong><\/p>\n\n\n\n<ol type=\"1\" class=\"has-medium-font-size wp-block-list\"><li>Makes code more readable and understandable.<ol><li>Helps to remember why certain blocks of code were written.<\/li><li>Can also be used to ignore some code while testing other blocks of code<strong>.<\/strong><\/li><\/ol><\/li><\/ol>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaeff0\"><strong>Single Line Comments in Python:<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaeff0\">The hash symbol #is used to write a single line comment.<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaeff0\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Printing a message\n\nprint(\u201c Enter your Name \u201c)\n\nmyName = input (\u201c Enter Your Name\u201d) # Read your name to myName<\/code><\/pre>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e9eced\"><strong>Multiline Comments in Python:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1. Using # at the beginning of each line of comment on multiple lines\n\nExample:\n\n# It is a\n\n# multiline\n\n# comment\n\n2. Using String Literals \u201d\u2019 at the beginning and end of multiple lines\n\nExample:\n\n\u201d\u2019 \n\nI am a\n\nMultiline comment!\n\n\u201d\u2019<\/code><\/pre>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e3e9eb\"><strong><em>The print() Function :<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e3e9eb\">The print function is used to display the string value written within pair of double quotes inside the parentheses on the screen .<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(\u2018It is Good to meet you, \u2018 + myName)\n\nprint(\u2018The length of your name is:\u2019)\n\nprint(len(myName))\n\nprint(\u2018You Will be \u2018 + str(int(myAge)+1) + \u2018 in a year.\u2019)<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>The line&nbsp;<\/strong><em>print(\u2018The length of your name is:\u2019)<\/em>&nbsp;means \u201cPrint out the text in the string \u2018\u2019The length of your name is:\u2019 . When Python executes the print statement, python interpreter calls the&nbsp;<em>print(<\/em>)function and the string value is being&nbsp;<em>passed<\/em>&nbsp;to the function. The value within print() is called argument . Quotes within parentheses marks where the string begins and ends ; they are not&nbsp; part of the string value.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>The input() function<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">This function is used to take the input from the&nbsp; user . Whatever the user enter as input, input() function convert it into a string . if you enter an integer&nbsp; value still input() function convert it into a string . The programmer is needed to convert it into an integer in your code using&nbsp;<em>typecasting<\/em>.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Myname = input(\u201cEnter your name\u201d)<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-14.png\" alt=\"\" class=\"wp-image-24296\" width=\"405\" height=\"241\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-14.png 667w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-14-300x179.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-14-600x357.png 600w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#dde3e6\"><strong>Reading multiple values using input()<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#dde3e6\">Programmer often want as user to enter multiple values in one line . In Python user can take multiple values or inputs in one line by using split() method . &nbsp;It breaks the given input by the specified separator. If separator is not provided then any white space is a separator. Generally, user use a&nbsp;split()&nbsp;method to split a Python string but one can used it in taking multiple input.<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#dde3e6\"><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;&gt;&gt;<strong> x, y,z = input (\u201cEnter three values\u201d).split()<\/strong>\nEnter three values 2 3 4\n\n&gt;&gt;&gt; x\n\u20182\u2019\n\n&gt;&gt;&gt; y\n\u20183\u2019\n\n&gt;&gt;&gt; z\n\u20184\u2019<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">In order to get the input from the user through the keyboard Python provides a built-in function called input. When this function is called, the program stops and waits for the user to type something. When the user presses Return or Enter, the program resumes and input returns what the user typed as a string<strong>.<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Example 1: Program to find the simple interest<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15.png\" alt=\"\" class=\"wp-image-24305\" width=\"735\" height=\"323\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15.png 975w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15-300x132.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15-768x338.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15-760x334.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-15-600x264.png 600w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e0e9ed\"><strong>Example 2 : Python Program to Add Two Numbers<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-16.png\" alt=\"\" class=\"wp-image-24307\" width=\"483\" height=\"154\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-16.png 763w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-16-300x96.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-16-760x242.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-16-600x191.png 600w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-17.png\" alt=\"\" class=\"wp-image-24311\" width=\"219\" height=\"45\"\/><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e8eff2\"><strong>The len() Function<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e8eff2\">&nbsp;In python len() function is used to find the number of characters in a given string&nbsp; as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-18.png\" alt=\"\" class=\"wp-image-24313\" width=\"345\" height=\"67\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-18.png 614w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-18-300x58.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-18-600x116.png 600w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#ebf2f5\"><strong>The str() , int() and float Functions :<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#ebf2f5\"><strong>str() function can be used convert integer or floating numbers into string data type.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-19.png\" alt=\"\" class=\"wp-image-24314\" width=\"147\" height=\"73\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Similarly&nbsp;int()&nbsp;and&nbsp;float()&nbsp;function will evaluate into integer and floating \u2013 point forms of the value you pass , respectively.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-20.png\" alt=\"\" class=\"wp-image-24315\" width=\"142\" height=\"232\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Note that if a values is passed to int() &nbsp;or float that they &nbsp;cannot evaluate as integer or float , Python will display an error message.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-21.png\" alt=\"\" class=\"wp-image-24319\" width=\"480\" height=\"149\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-21.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-21-300x93.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-21-760x237.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-21-600x187.png 600w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">The&nbsp;<strong>int()<\/strong>&nbsp;function can be used to round a floating point number down as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-22.png\" alt=\"\" class=\"wp-image-24321\" width=\"165\" height=\"66\"\/><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#b8c4c8\"><strong>1.13&nbsp;Operators and operands<\/strong><\/p>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li>Operators are special symbols that represent computations like addition and multiplication. The values the operator is applied to are called operands.<\/li><li>The operators&nbsp;<strong>+, -, *, \/, and **&nbsp;<\/strong>perform&nbsp;<em>addition, subtraction, multiplication, division, and exponentiation<\/em>, as in the following examples:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Operator<\/strong><\/td><td><strong>Operation<\/strong><\/td><td><strong>Example<\/strong><\/td><td><strong>Evaluates to<\/strong><\/td><\/tr><tr><td><strong>**<\/strong><\/td><td><strong>Exponent<\/strong><\/td><td><strong>5**3<\/strong><\/td><td><strong>125<\/strong><\/td><\/tr><tr><td><strong>%<\/strong><\/td><td><strong>Modulus\/Remainder<\/strong><\/td><td><strong>33%7<\/strong><\/td><td><strong>5<\/strong><\/td><\/tr><tr><td><strong>\/\/<\/strong><\/td><td><strong>Integer Division\/Floored quotient<\/strong><\/td><td><strong>33\/\/5<\/strong><\/td><td><strong>6<\/strong><\/td><\/tr><tr><td><strong>\/<\/strong><\/td><td><strong>Division<\/strong><\/td><td><strong>23\/7<\/strong><\/td><td><strong>3.2857142857142856<\/strong><\/td><\/tr><tr><td><strong>*<\/strong><\/td><td><strong>Multiplication<\/strong><\/td><td><strong>7*8<\/strong><\/td><td><strong>56<\/strong><\/td><\/tr><tr><td><strong>\u2013<\/strong><\/td><td><strong>Subtraction<\/strong><\/td><td><strong>8 \u2013 5<\/strong><\/td><td><strong>3<\/strong><\/td><\/tr><tr><td><strong>+<\/strong><\/td><td><strong>Addition<\/strong><\/td><td><strong>7+ 3<\/strong><\/td><td><strong>10<\/strong><\/td><\/tr><\/tbody><\/table><figcaption><strong>Table:&nbsp; Operators and Examples<\/strong><\/figcaption><\/figure>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#dbe8ed\"><strong>Order of operations<\/strong><\/p>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li>When more than one operator appears in an expression, the order of evaluation depends on the rules of precedence.<\/li><\/ul>\n\n\n\n<p class=\"has-medium-font-size\"><strong>PEMDAS<\/strong>&nbsp;order of operation is followed in Python:<\/p>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li><strong>Parentheses<\/strong>&nbsp;have the highest precedence and can be used to force an expression to evaluate in the order you want.<\/li><li><strong>Exponentiation<\/strong>&nbsp;has the next highest precedence,<\/li><li><strong>Multiplication and Division&nbsp;<\/strong>have the same precedence, which is higher than<\/li><li><strong>Addition and Subtraction<\/strong>, which also have the same precedence.<\/li><li><strong>Operators with the same precedence<\/strong>&nbsp;are evaluated from left to right.<\/li><\/ul>\n\n\n\n<p class=\"has-medium-font-size\">Following examples illustrates the evaluation of expressions by Python interpreter. In each case the programmer must enter the expression , python interpreter evaluates the expression to a single value .<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;&gt;&gt; 5+4*3\n17\n\n&gt;&gt;&gt; (4+5)*3\n27\n\n&gt;&gt;&gt; 12345678*45678\n563925879684\n\n&gt;&gt;&gt; 3**5\n243\n\n&gt;&gt;&gt; 22\/\/7\n3\n\n&gt;&gt;&gt; 22\/7\n3.142857142857143\n\n&gt;&gt;&gt; 27%5\n2\n\n&gt;&gt;&gt;3  +   3\n6\n\n&gt;&gt;&gt; (5-2)*((8+4)\/(5-2))\n12.0\n\nPython interpreter evaluates parts of the expression as per the PEMDAS rule until it becomes a single value as illustrated below :\n\n(5-2)*((8+4)\/(5-2))\n\n3 * ((8+4)\/(5-2))\n\n3*(12\/(5-2))\n\n3*(12\/3)\n\n3*4.0\n\n12.0<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Note:<\/strong>&nbsp;If you type invalid expressions, python interpreter will not be able to understand it and will display a Syntax Error message as illustrated below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-23.png\" alt=\"\" class=\"wp-image-24332\" width=\"239\" height=\"111\"\/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.14 String Concatenation and Replication<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">The functionality of the operator may change based on the data types of operand used . For example + which is the addition operator when it operated on two integers&nbsp; or floating \u2013 point values , can be used to concatenate two strings&nbsp; as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-24.png\" alt=\"\" class=\"wp-image-24336\" width=\"350\" height=\"75\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-24.png 600w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-24-300x65.png 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Similarly * operator which is multiplication operator can be used as string replication operator when string is multiplied with a number as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-25.png\" alt=\"\" class=\"wp-image-24338\" width=\"516\" height=\"69\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-25.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-25-300x40.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-25-760x101.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-25-600x80.png 600w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/figure>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.15&nbsp;<u>Python Character Set:<\/u><\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">The set of valid characters recognized by Python like letter, digit or any other symbol . The latest version of Python recognizes Unicode character set. Python supports the following character set:<\/p>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li><strong>Letters&nbsp;<\/strong>: A-Z ,a-z<\/li><li><strong>Digits<\/strong>&nbsp;:0-9<\/li><li><strong>Special Symbols&nbsp;<\/strong>: space +-\/*\\**()[]{}\/\/=!= == &lt;&gt; ,\u201d\u201d\u201d,;:%!#?$&amp;^\u00f3=@_<\/li><li><strong>White Spaces<\/strong>&nbsp;: Blank Space, tabs(-&gt;), Carriage return , new line , form feed<\/li><li><strong>Other Characters<\/strong>&nbsp;: All other 256 ACII and Unicode characters<\/li><\/ul>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.16&nbsp;<u>Python Tokens<\/u>:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">A token (lexical unit) is the smallest element of Python script that is meaningful to the interpreter . Python has following categories of tokens: Identifiers, Keywords , Literals , operators&nbsp; and delimiters.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Identifiers:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Identifiers are names that you give to a variable , class or Function. There are certain rules for naming identifiers similar to the variable declaration rules , such as : No Special character except_ , Keywords are not used as identifiers , the first character of an identifier should be _ underscore or a character , but a number is not valid for identifiers and identifiers are case sensitive .<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Literals:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">A fixed numeric or non-numeric value is called a literal . Literals may be string, numbers (int, long, float and complex), Boolean (True or False), NONE and Operators.<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\"><strong>Operators :<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\">A Symbol or a word that performs some kind of operation on given values and returns the result. There are 7&nbsp; types of operators available for Python: Arithmetic Operator ,Assignment Operator, Comparison Operator, Logical Operator , Bitwise Operator , Identity Operator and&nbsp; Membership Operator .<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\"><strong>Delimiters<\/strong>:<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\">Delimiters are the symbols which can be used as separators of values or to enclose some values. Examples of delimiters are () {} [],;:<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\"><strong>Note :<\/strong>&nbsp;Comments and # symbol used to insert a comment is not a&nbsp; token.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\" style=\"background-color:#eaf2f5\"><strong>Keywords:<\/strong><\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#eaf2f5\">The reserved words of Python which have a special fixed meaning for the interpreter are called keywords. No keyword can be used as an identifier or variable names. There are 35 keywords in python as listed below:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Keyword<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>and<\/td><td>Logical and operator<\/td><\/tr><tr><td>as<\/td><td>Alias<\/td><\/tr><tr><td>assert<\/td><td>Used for debugging<\/td><\/tr><tr><td>async<\/td><td>Used to &nbsp;make a function asynchronous by adding the&nbsp;async&nbsp;keyword before the function\u2019s regular definition<\/td><\/tr><tr><td>await<\/td><td>Used in asynchronous functions to specify a point in the function where control is given back to the event loop for other functions to run. You can use it by placing the&nbsp;await&nbsp;keyword in front of a call to any&nbsp;async&nbsp;function<\/td><\/tr><tr><td>break<\/td><td>To break out of a loop<\/td><\/tr><tr><td>class<\/td><td>To define a class<\/td><\/tr><tr><td>continue<\/td><td>For skipping the statements and conitinuing the next iteration<\/td><\/tr><tr><td>def<\/td><td>For defining user defined functions<\/td><\/tr><tr><td>del<\/td><td>To delete an object<\/td><\/tr><tr><td>elif<\/td><td>Conditional statement, same as else if<\/td><\/tr><tr><td>else<\/td><td>Conditional statement<\/td><\/tr><tr><td>except<\/td><td>Used in exception handling<\/td><\/tr><tr><td><strong>False<\/strong><\/td><td>Boolean Value<\/td><\/tr><tr><td>finally<\/td><td>Used in exception handling , to execute a block of code no matter whether exception is there or not<\/td><\/tr><tr><td>for<\/td><td>Used to create for loop \u2013 iterative statement<\/td><\/tr><tr><td>from<\/td><td>Used to import specific parts of a module<\/td><\/tr><tr><td>global<\/td><td>Used to declare global variable<\/td><\/tr><tr><td>if<\/td><td>Conditional \/decision making statement<\/td><\/tr><tr><td>import<\/td><td>Used to import a module or library<\/td><\/tr><tr><td>in<\/td><td>Used to check if a value if present in list, tuple, dictionaries , sets ,etc.<\/td><\/tr><tr><td>is<\/td><td>To check if two variables are equal<\/td><\/tr><tr><td>lambda<\/td><td>Used for defining an anonymous function<\/td><\/tr><tr><td><strong>None<\/strong><\/td><td>Used to represent a null value<\/td><\/tr><tr><td>nonlocal<\/td><td>To declare a non-local variable<\/td><\/tr><tr><td>not<\/td><td>A logical operator<\/td><\/tr><tr><td>or<\/td><td>A logical operator<\/td><\/tr><tr><td>pass<\/td><td>A null statement , a statement that will do nothing<\/td><\/tr><tr><td>raise<\/td><td>To raise an exception<\/td><\/tr><tr><td>return<\/td><td>To exit a function and return a value<\/td><\/tr><tr><td><strong>True<\/strong><\/td><td>Boolean Value<\/td><\/tr><tr><td>try<\/td><td>Used in exception handling<\/td><\/tr><tr><td>while<\/td><td>For creating a while iterative loop<\/td><\/tr><tr><td>with<\/td><td>Used to simplify exception handling<\/td><\/tr><tr><td>yield<\/td><td>To end a function , returns a generator<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Following code segment can be used to obtain the list of python keywords :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>import keyword<\/strong>\n<strong>len(keyword.kwlist)  <\/strong>\n#ouput:\n36\n<strong>print(keyword.kwlist)<\/strong>\n#output:\n&#91;'False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.17 Installing Jupyter Notebook<\/strong><\/p>\n\n\n\n<p>[ source :&nbsp;<a href=\"https:\/\/test-jupyter.readthedocs.io\/en\/latest\/install.html\">https:\/\/test-jupyter.readthedocs.io\/en\/latest\/install.html<\/a>&nbsp;]<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Prerequisite:<\/strong>&nbsp;Jupyter requires Python ( Python 3.3 or greater or Python2.7) for installing the Jupyter Notebook. Anaconda distribution is recommended for installing Python and Jupyter .<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Installing Jupyter using Anaconda and conda<\/strong>:<\/p>\n\n\n\n<p class=\"has-medium-font-size\">To install anaconda, one must download the installation package of the required version from the link\/ULR: https:\/\/www.anaconda.com\/products\/individual .<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26.png\" alt=\"\" class=\"wp-image-24343\" width=\"646\" height=\"244\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26.png 975w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26-300x114.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26-768x291.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26-760x288.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-26-600x228.png 600w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">For Windows and for Python 3.8 there is 64 \u2013 Bit and 32-Bit Graphical Installer. Once the appropriate Anaconda installer is downloaded and installed successfully , one can find the Jupyter appearing in the Anaconda folder as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"229\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-27.png\" alt=\"\" class=\"wp-image-24345\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Click the Jupyter Note Book , Server and all Kernels at background will open as illustrated below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"356\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28.png\" alt=\"\" class=\"wp-image-24348\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28.png 975w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28-300x110.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28-768x280.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28-760x277.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-28-600x219.png 600w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Soon after the Server is launched, Jupyter notebook will get open. Also, one can open the Jupyter notebook by copy and pasting any one of the following URLs as displayed in the message box:<\/p>\n\n\n\n<p>http:\/\/localhost:8888\/?token=f4a177b84feea3ad6fd6f6fe0f57f69d6d6f7894c4f30008<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp; or http:\/\/127.0.0.1:8888\/?token=f4a177b84feea3ad6fd6f6fe0f57f69d6d6f7894c4f30008<\/p>\n\n\n\n<p class=\"has-background has-medium-font-size\" style=\"background-color:#e1e6e8\"><strong>Jupyter Notebook editor will open as illustrated below:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"393\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29.png\" alt=\"\" class=\"wp-image-24349\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29.png 975w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29-300x121.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29-768x310.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29-760x306.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-29-600x242.png 600w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">In order to open a new python file, one should click new button and select Python3 , as below :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-30.png\" alt=\"\" class=\"wp-image-24351\" width=\"241\" height=\"223\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">A new untitled Python file with one cell will get open:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"191\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31.png\" alt=\"\" class=\"wp-image-24353\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31.png 974w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31-300x59.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31-768x151.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31-760x149.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-31-600x118.png 600w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Type the python code and execute by clicking Run button :<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-32.png\" alt=\"\" class=\"wp-image-24354\" width=\"539\" height=\"183\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-32.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-32-300x102.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-32-760x258.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-32-600x204.png 600w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/figure>\n\n\n\n<p><strong>Reference Video Link : <a href=\"https:\/\/youtu.be\/bkOEYmyMtEU\">How to Install Anaconda and Jupyter Notebook on Windows 10 \/11 <\/a><\/strong><\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.18 Questions for Practice:<\/strong><\/p>\n\n\n\n<ol type=\"1\" class=\"has-medium-font-size wp-block-list\"><li>What is Python ? Who created Python?<\/li><li>What are the features of Python which makes it more popular?<\/li><li>List out the different jobs available for Python programmer.<\/li><li>What is the role of programmer? Lis two skills required to become good programmer.<\/li><li>Discuss, Why Should you learn to write Programs?<\/li><li>What is Zen of Python?<\/li><li>Discuss, with snapshots how to install latest version of IDLE Python and Jupyter Python.<\/li><li>Illustrate with examples how to interact with IDLE Python.<\/li><li>Explain how mathematical expressions can be executed in interactive shell.<\/li><li>Illustrate with example how write and execute programs in Jupyter Editor.<\/li><li>Explain the different components of Jupyter Editor.<\/li><li>Define Program. Differentiate between Compiler and Interpreter. Give Examples.<\/li><li>What are Python words and sentences? Explain with an example for each.<\/li><li>Classify the following list of items into variables, values, operators, strings, and keywords: [<strong>List of items:<\/strong>&nbsp; *,&nbsp;&nbsp; + , \u2013 , **, &lt; ,&gt;&nbsp; , \u2018hello\u2019&nbsp; , \u2018 I am ok . How are you\u2019, -88.8, \/, 5, and, is , not , while , for, async, x, si, p , time , rate , velocity , speed, acc&nbsp; , % ,&amp;, ! , ||]<\/li><li>What are expressions? Illustrate the different types of expressions with examples.<\/li><li>&nbsp;What are data types? Classify the different data types in python with examples.<\/li><li>What are Python Variables? What rules one should follow to name the variables.<\/li><li>Give 5 examples for valid and invalid variables.<\/li><li>Discuss how to store values in a variable.<\/li><li>Write a sample program and dissect the program with explanation.<\/li><li>What are comments? What are the advantages of Comments? Explain the different ways of writing comments.<\/li><li>Give examples for single and multiline comments.<\/li><li>Explain the working and usage of&nbsp; print() function with examples.<\/li><li>Explain the working and usage of&nbsp; input() function with examples.<\/li><li>Give example to read multiple values using input().<\/li><li>Define operands and operators. Discuss PEMDAS rules with examples.<\/li><li>What are keywords? How many keywords are there in current version of Python?<\/li><li>Write a program to display all keywords in the current version of Python.<\/li><li>What are Python comments? Explain their importance with programming examples.<\/li><li>Explain print () , input()&nbsp; and split() functions with example.<\/li><li>Write a program for the following:<ul><li>To read and print a single value in a single line<\/li><li>To read and print multiple values in a single line<\/li><\/ul><\/li><li>&nbsp;Explain the following different types of errors: Syntax errors, Semantic errors and Logic Errors.<\/li><li>Explain the following functions with example: len()&nbsp; , str() , int() , float()<\/li><li>Predict the out put and justify your answer: (i) -11%9&nbsp;&nbsp; (ii) 7.7\/\/7&nbsp; (iii) (200 \u2013 70)*10\/5&nbsp;&nbsp; (iv) not&nbsp; \u201cFalse\u201d&nbsp;&nbsp;&nbsp;&nbsp; (v) 5*|**2<\/li><li>List the rules to describe a variable in Python. Demonstrate at least three different types of variables uses with an example program.<\/li><li>Explain the following :<ul><li>Skills necessary for a programmer<\/li><li>Interactive Mode<\/li><li>Short circuit evaluation of expression<\/li><li>Modulus operator.<\/li><\/ul><\/li><li>Mention three types of errors encountered in python program.<\/li><li>Define the following with example : Values and Types , Variables , Expressions , Keywords , Statements , Operators and Operands, Order of Operations , Modulus Operators , String operations and Comments.<\/li><li>What three functions can be used to get the integer, floating-point number, or string version of a value?<\/li><\/ol>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background has-medium-font-size\"><strong>1.19 Programs for Practice:<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Write and execute python programs for the following :<\/strong><\/p>\n\n\n\n<ol type=\"1\" class=\"has-medium-font-size wp-block-list\"><li>To prompt a user for their name and then welcomes them.<\/li><li>To prompt a user for days and rate per day to compute gross salary.<\/li><li>To read the following input and display :<ol><li>Name :<\/li><li>USN:<\/li><li>Roll No:<\/li><li>Mobile No:<\/li><li>E-Mail Id:6. Percentage of Marks<\/li><\/ol><\/li><li>To find the simple interest for a given value of P, T and R. Program should take input from the user.<\/li><li>To find the compound interest.<\/li><li>To read two integers and find the sum, diff, mult and div.<\/li><li>To Convert given Celsius to Fahrenheit temperature.<\/li><li>To print ascii value of a character.<\/li><li>To display all the keywords.<\/li><li>To print the following string in a specific format :\u201d\u201dTwinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are\u201d&nbsp;.<\/li><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"222\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2023\/03\/image-33.png\" alt=\"\" class=\"wp-image-24357\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">11. To get a python version.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">12. To display the current date and time<\/p>\n\n\n\n<p class=\"has-medium-font-size\">13. To accept the radius of a circle from the user and compute the area.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">14. To print the calendar of a given month and year.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">15. To check whether a file exists .<\/p>\n\n\n\n<p class=\"has-medium-font-size\">16. To determine if a Python shell is executing in 32 bit or 64 bit mode on OS.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">17. To get OS name , platform and release information .<\/p>\n\n\n\n<p class=\"has-medium-font-size\">18. To locate Python site packages.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">19. To call an external command in python.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">20. To get path and name of the file that is currently executing.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">21. To parse a string to float or integer.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">22. To list all files in a directory in Python.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">23. To print without newline or space.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">24. To determine profiling of Python programs.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">25. To print to stderr.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">26. To access environment variables.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">27. To get the current username.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">28. To find the local IP addresses using Pythons stdlib.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">29. To get execution time for a python method.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">30. To convert height in meters to centimeters.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">31. To Convert all units of time to seconds<\/p>\n\n\n\n<p class=\"has-medium-font-size\">32. To convert the distance in feet to inches , yards and miles.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">33. To calculate body mass index.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">34. Given variables x = 15 and y = 30 , write a Python program to print \u201c15+30=45\u201d.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">35. To get the identity of the object<\/p>\n\n\n\n<p class=\"has-medium-font-size\">36. To check whether a string is numeric.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">37. To get the system time .<\/p>\n\n\n\n<p class=\"has-medium-font-size\">38.To clear the screen or terminal<\/p>\n\n\n\n<p class=\"has-medium-font-size\">39.To calculate the time runs (difference between start and current time ) of a program.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">40.To input integer if not generate error.<\/p>\n\n\n\n<p>********************************************************************************************<\/p>\n\n\n\n<p style=\"font-size:30px\"><strong>Questions and Answers : <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\">1<strong>. What is Python ? Who created Python?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Python is a high-level, interpreted programming language that was first released in 1991 by Guido van Rossum. It is designed to be easy to read and write, with a simple and elegant syntax that emphasizes code readability.\n\nPython is a dynamically typed language, meaning that variable types are determined at runtime, and it supports multiple programming paradigms, including procedural, object-oriented, and functional programming.\n\nPython is widely used in various industries, including web development, data science, artificial intelligence, scientific computing, and more. It has a vast and active community of developers who contribute to its development and create numerous libraries and frameworks to extend its capabilities.\n\nGuido van Rossum started the development of Python in the late 1980s while working at the National Research Institute for Mathematics and Computer Science in the Netherlands. He wanted to create a language that was easy to learn and use, with a focus on code readability and simplicity.\n\nToday, Python is one of the most popular programming languages in the world, with a large and growing user base. Its popularity is due to its ease of use, versatility, and wide range of applications.<\/code><\/pre>\n\n\n\n<p>2. What are the features of Python which makes it more popular?<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Python has gained widespread popularity due to its numerous features that make it a powerful and versatile programming language. Some of the features that contribute to Python's popularity are:\n\n<strong>Easy to learn and use<\/strong>: Python has a simple and intuitive syntax that is easy to read and write, making it an ideal language for beginners.\n\n<strong>Large and active community:<\/strong> Python has a vast and active community of developers who contribute to its development and create numerous libraries and frameworks to extend its capabilities.\n\n<strong>Cross-platform compatibility:<\/strong> Python is a cross-platform language, meaning that code written in Python can run on multiple operating systems without any modifications.\n\n<strong>Dynamically typed: <\/strong>Python is dynamically typed, meaning that variable types are determined at runtime, making it more flexible and easier to use.\n\n<strong>High-level language:<\/strong> Python is a high-level language, meaning that it abstracts away low-level details of the machine, making it easier to write code quickly.\n\n<strong>Object-oriented:<\/strong> Python supports object-oriented programming, allowing developers to create reusable and modular code.\n\n<strong>Extensive standard library<\/strong>: Python comes with a vast standard library that provides a wide range of functionalities, such as working with files, network programming, database access, and more.\n\n<strong>Interpreted:<\/strong> Python is an interpreted language, meaning that code is executed line by line, making it easier to test and debug code.\n\n<strong>Scalable:<\/strong> Python can be used for small and large-scale projects alike, and it is scalable due to its support for modules, packages, and third-party libraries.\n\n<strong>Data science and machine learning support<\/strong>: Python has gained popularity in the data science and machine learning community due to its extensive libraries such as NumPy, Pandas, Matplotlib, and more.\n\nOverall, these features make Python a popular and versatile language that is used in a wide range of industries, from web development to scientific computing to artificial intelligence.<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Syllabus : Python Basics: Introduction, Entering Expressions into the Interactive Shell, The Integer, Floating-Point, and String Data Types, String Concatenation and Replication, Storing Values in Variables, Your First Program, Dissecting&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-24239","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/24239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/comments?post=24239"}],"version-history":[{"count":69,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/24239\/revisions"}],"predecessor-version":[{"id":25815,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/24239\/revisions\/25815"}],"wp:attachment":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/media?parent=24239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}