December 4, 2024

Tirth's Blog

My technical notes

Python Basics: Variables and Data Types

In this tutorial, we’ll explore the basics of Python programming, focusing on variables and data types.
Understanding these concepts is crucial for writing efficient code.

### Variables in Python

A variable is a container for storing data values. Python variables do not require an explicit declaration to
reserve memory space.

Example of variables:
x = 10
y = “Hello, Python!”
z = 3.14
print(x, y, z)

### Data Types

Python supports various data types. The most common ones include:

– **int**: Integer numbers.
– **float**: Floating-point numbers.
– **str**: Strings (text).
– **bool**: Boolean values (True/False).

Example of data types:
is_valid = True
name = “Alice”
score = 95.5
print(type(is_valid), type(name), type(score))

About The Author

Copyright © All rights reserved. | Newsphere by AF themes.