Author: admin

  • Python while

    Summary: in this tutorial, you’ll learn about the Python while statement and how to use it to run a code block as long as a condition is true. Introduction to the Python while statement Python while statement allows you to execute a code block repeatedly as long as a condition is True. The following shows the syntax of the Python while statement: The condition is an…

  • Python for Loop with Range

    Summary: in this tutorial, you’ll learn about the Python for loop and how to use it to execute a code block a fixed number of times. Introduction to Python for loop statement with the range() function In programming, you often want to execute a block of code multiple times. To do so, you use a for loop. The following…

  • Python Ternary Operator

    Summary: in this tutorial, you’ll learn about the Python ternary operator and how to use it to make your code more concise. Introduction to Python Ternary Operator The following program prompts you for your age and determines the ticket price based on it: Here is the output when you enter 18: In this example, the…

  • Python if Statement

    Summary: in this tutorial, you’ll learn how to use the Python if statement to execute a block of code based on a condition. The simple Python if statement You use the if statement to execute a block of code based on a specified condition. The syntax of the if statement is as follows: The if statement checks the condition first. If the condition…

  • Python Logical Operators

    Summary: in this tutorial, you’ll learn about Python logical operators and how to use them to combine multiple conditions. Introduction to Python logical operators Sometimes, you may want to check multiple conditions at the same time. To do so, you use logical operators. Python has three logical operators: The and operator The and operator checks whether two conditions are…

  • Python Comparison Operators

    Summary: in this tutorial, you’ll learn about Python comparison operators and how to use them to compare two values. Introduction to Python comparison operators In programming, you often want to compare a value with another value. To do that, you use comparison operators. Python has six comparison operators, which are as follows: These comparison operators…

  • Python Type Conversion

    Summary: in this tutorial, you’ll learn about type conversion in Python and some useful type conversion functions. Introduction to type conversion in Python To get input from users, you use the input() function. For example: When you execute this code, it’ll prompt you for input on the Terminal:Enter a value: If you enter a value, for example,…

  • Python Comments

    Summary: in this tutorial, you’ll learn how to add comments to your code. And you’ll learn various kinds of Python comments including block comments, inline comments, and documentation string. Introduction to Python comments Sometimes, you want to document the code that you write. For example, you may want to note why a piece of code…

  • Python Constants

    Summary: in this tutorial, you’ll learn how to define Python constants. Sometimes, you may want to store values in variables. But you don’t want to change these values throughout the execution of the program. To do it in other programming languages, you can use constants. The constants are like variables but their values don’t change during…

  • Python Boolean

    Summary: in this tutorial, you’ll learn about the Python boolean data type, falsy and truthy values. Introduction to Python Boolean data type In programming, you often want to check if a condition is true or not and perform some actions based on the result. To represent true and false, Python provides you with the boolean…