Type Conversion in Python

The data type is the classification of data items it tells the interpreter how a is intended to use the data. Python has various data types and a variable is automatically declared on the basis of the value that you assign to it. Sometimes a data type is needed to be converted to another … Read more

Python Numeric Data Types

Numeric data types are numbers stored in the memory. You can perform operations such as addition, subtraction, multiplication, division, modulo, etc on numeric data. The following data types can be categorized as numeric types. int float complex Integer type Integers are the whole numbers means there are no floating-point values in them. A variable of … Read more

How to sort a list in Python?

A Python list data type can hold multiple different types of values in a single variable. It is a collection of ordered and changeable data items. The given example shows a list in Python. list1=[‘Python’, ‘programming’, 2021] A list can have unsorted elements to sort them in a specific ascending or descending order Python provides two built-in … Read more

How to Check Armstrong number in Python?

A number is called an Armstrong number if the sum of its own digits each raised to the power of the number of digits. We can write in its generalized form as – abcd..= an+bn+cn+dn+… It is named after Michael F. Armstrong the Armstrong number is known with some other names – Narcissistic number pluperfect … Read more

How to find length of a list in python?

A Python list data type can hold multiple different types of values in a single variable. It is a collection of ordered and changeable data items. A list in Python can have duplicate data items. The given example shows a list in Python. list1=[‘Python’, ‘programming’, 2021] For determining the length of a list, Python provides … Read more

Python Dictionary Comprehension

Python dictionary data type is used to store data in key:value pairs. It can be created in two ways first is by placing the comma-separated items inside curly braces and the second is to create using dict() function. For example – s={1:’Ankit’, 2:’Sumit’, 3:’John’, 4:’Vinay’} Python dictionary comprehension provides a shorter syntax to create dictionaries. In … Read more

Using Python break and continue keywords

The break and continue are keywords used in Python to alter the normal flow of loops. A loop iterate over a line or block of code repeatedly until the given condition becomes false. Now, what if you want to continue or exit from the loop immediately after a certain condition meets, you can do this … Read more

Python List vs Array

Like in many other programming languages Python also provides some inbuilt data types this includes list, tuple, sets, dictionaries, etc. In this article, we will discuss the similarities and differences between lists and arrays. The list data type is exclusively used in Python. You can use this to store multiple values in a single variable. … Read more

Keywords In Python

Like other programming languages, Python also has some reserved words whose meaning is already defined by the Python interpreter these reserved words are known as Keywords. A keyword cannot be used as the identifier. For example, you can not use a variable with the name def because it is a Python keyword that is used … Read more

Using Python keyword

The Python keyword which is a statement in itself basically does nothing. It can be used as a placeholder for future code. As empty code is not allowed in the loop’s body, Python conditional statements, functions definition, class definition, etc so by using the keyword you can avoid these errors. In this article, … Read more