Category: 2. Python Data Types

  • What is Type Conversion in Python?

    Traditional type conversion is a common problem that may be readily solved by using the built-in converters in Python modules. However, in a more sophisticated case, such as for keys in a list of dictionaries, we may require the same capability.  Let’s look at several options for accomplishing this. Naive Method in Python We use…

  • What is Python Dictionary?

    A dictionary in Python is an unordered group or collection of data values that may be used to store data values in the same way that a map can.  Unlike other data types, which can only carry a single value as an element, dictionaries can hold a key-value pair. The dictionary includes a key-value pair…

  • What are Sets in Python?

    Sets allow you to store several items in a single variable. Set is one of the four built-in Python data types for storing collections of data. The other three are List, Tuple, and Dictionary, all of which have various properties and applications.A set is an unsorted, unchangeable, and unindexed collection. How to Create Python Sets?…

  • What are Tuples in Python?

    Tuples store an ordered list of items, and are unchangeable. This signifies that the values of a tuple can’t be changed. Parentheses are used to define tuples. In Python, a tuple is a basic data structure. They let you keep a list of objects in a specific order. A tuple can be used to hold…

  • What are Lists in Python?

    Lists are ordered collections of data, similar to arrays, which are defined in other languages. It’s particularly adaptable because list elements don’t have to be of the same type.  How to Create a List in Python? You can make a list in Python by simply putting the sequence inside square brackets[]. Output: Initial blank List:  []…

  • What are Strings in Python?

    Strings are text fragments. They can be defined as anything that falls between two quotation marks: astring = “Welcome to WSC!” astring1 = Welcome to WSC’ astring2 = “”” Welcome to WSC “”” As you can see, you learned how to print a basic sentence initially. Python has saved this phrase as a string. Instead…

  • What are Numbers in Python?

    Integers, floating-point numbers, and complex numbers are all supported in Python. In Python, they are known as int, float, and complex classes.  The presence of a decimal point distinguishes integers from floating points. For example, the number 5 is an integer, but the number 5.0 is a floating-point number.  The formula for complex numbers is…

  • What are Data Types in Python?

    Data types are the classification/categorization of data components. It refers to a value that describes which operations may be performed on a collection of data. Since everything in Python programming is an object, data types are basically classes, and variables are instances (objects) of these classes. Getting Data Type in Python The type() method can be used…