Category: Tutorials

  • Loops

    Python Loops Python loops allow us to execute a statement or group of statements multiple times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of…

  • Match-Case Statement

    Python match-case Statement A Python match-case statement takes an expression and compares its value to successive patterns given as one or more case blocks. Only the first pattern that matches gets executed. It is also possible to extract components (sequence elements or object attributes) from the value into variables. With the release of Python 3.10, a pattern matching…

  • Nested if Statement

    Python supports nested if statements which means we can use a conditional if and if…else statement inside an existing if statement. There may be a situation when you want to check for additional conditions after the initial one resolves to true. In such a situation, you can use the nested if construct. Additionally, within a nested if construct, you can include an if…elif…else construct inside another if…elif…else construct. Syntax of…

  • Else Statement

    Python if else Statement The if-else statement in Python is used to execute a block of code when the condition in the if statement is true, and another block of code when the condition is false. Syntax of if-else Statement The syntax of an if-else statement in Python is as follows − If the boolean expression evaluates to TRUE,…

  • if Statement

    Python If Statement The if statement in Python evaluates whether a condition is true or false. It contains a logical expression that compares data, and a decision is made based on the result of the comparison. Syntax of the if Statement If the boolean expression evaluates to TRUE, then the statement(s) inside the if block is executed. If boolean expression evaluates…

  • Decision Making

    Python’s decision making functionality is in its keywords − if..elif…else. The if keyword requires a boolean expression, followed by colon (:) symbol. The colon (:) symbol starts an indented block. The statements with the same level of indentation are executed if the boolean expression in if statement is True. If the expression is not True (False), the interpreter bypasses the indented block and proceeds…

  • Control Flow

    Python program control flow is regulated by various types of conditional statements, loops, and function calls. By default, the instructions in a computer program are executed in a sequential manner, from top to bottom, or from start to end. However, such sequentially executing programs can perform only simplistic tasks. We would like the program to have a decision-making ability,…

  • Booleans

    Python Booleans (bool) In Python, bool is a sub-type of int type. A bool object has two possible values, and it is initialized with Python keywords, True and False. Example A bool object is accepted as argument to type conversion functions. With True as argument, the int() function returns 1, float() returns 1.0; whereas for False, they return 0 and 0.0 respectively. We…

  • Numbers

    Python has built-in support to store and process numeric data (Python Numbers). Most of the times you work with numbers in almost every Python application. Obviously, any computer application deals with numbers. This tutorial will discuss about different types of Python Numbers and their properties. Python – Number Types There are three built-in number types available in…

  • User Input

    Provide User Input in Python In this chapter, we will learn how Python accepts the user input from the console, and displays the output on the same console. Every computer application should have a provision to accept input from the user when it is running. This makes the application interactive. Depending on how it is…