Course Content
Variables, Data types
Python is a versatile programming language known for its simplicity and readability. One of the foundational concepts in Python is the use of variables and data types. This blog post will guide you through the basics of variables, different data types, and how to perform type casting in Python.
0/2
Type Casting in Python
Type casting refers to the conversion of one data type to another. In Python, you can cast variables from one type to another using built-in functions. Integer to Float: x = 10 y = float(x) print(y) # Output: 10.0
0/1
Python Programming For Beginners

A variable in Python is a symbolic name that is a reference or pointer to an object. Once an object is assigned to a variable, you can refer to the object by that name.

x = 10 y = "Hello, World!"

In the example above, x is a variable that holds an integer value 10, and y is a variable that holds a string value "Hello, World!".

Python Data Types

Python supports various data types. Some of the most commonly used data types include:

  1. Integers (int): Whole numbers without a fractional part.
  2. Floating-point numbers (float): Numbers with a fractional part.
  3. Strings (str): A sequence of characters.
  4. Booleans (bool): Represents True or False.
  5. Lists (list): An ordered collection of values.
  6. Tuples (tuple): An ordered, immutable collection of values.
  7. Dictionaries (dict): A collection of key-value pairs.
#integers (int)
age = 25

#floating point (float)
temperature = 98.6

#String (str)
name = "Alice"

#booleans (bool)
is_active = True

#Lists (list)
fruits = ["apple", "banana", "cherry"]

#Tuples (tuple)
coordinates = (10.0, 20.0)

#Dictionaries (dict)
person = {"name": "John", "age": 30}