Blog

python tutorials and learn python

Created with Sketch.

Python Ternary Operator

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: age = input(‘Enter your age:’) if int(age) >=…
Read more

Python if Statement

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…
Read more

Python Logical Operators

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: and or not The…
Read more

Python Comparison Operators

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:…
Read more

Python Type Conversion

Python Type Conversion   Summary: in this tutorial, you’ll learn about the type conversion in Python and some useful type conversion functions. Introduction to type conversion in Python To get an input from users, you use the input() function. For example: value = input(‘Enter a value:’) print(value) Code language: Python (python) When you execute this…
Read more

Python Comments

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…
Read more

Python Constants

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 like variables but their values…
Read more

Python Boolean

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…
Read more

Python Numbers

Python Numbers   Summary: in this tutorial, you’ll learn about Python numbers and how to use them in programs. Python supports integers, floats, and complex numbers. This tutorial discusses only integers and floats. Integers The integers are numbers such as -1, 0, 1, 2, 3, .. and they have type int. You can use Math…
Read more

Python String

Python String   Summary: in this tutorial, you’ll learn about Python string and its basic operations. Introduction to Python string A string is a series of characters. In Python, anything inside quotes is a string. And you can use either single or double quotes. For example: message = ‘This is a string in Python’ message…
Read more