×

To install this app on your iPhone, tap Share 🔗 then Add to Home Screen.

06 Introduction to Python Variables

0
62

Basically, Python has no command to Declare a Variable. A Variable is created as soon as you assign any value to it. Whether it is numeric, String, Float, Boolean or any kind.

Variables do not need to be declared with any particular type, and can even change type after they have been set.

*** Variable names in Python are case-sensitive.

A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume)

Following are some rules to create a variable name:

  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)

Example 01:

x = 5
y = "John"
print(x)
print(y)

Example 02:

x = 4       # x is of type int
x = "Sally" # x is now of type str
print(x)

Example 03:

x = str(3)    # x will be '3'
y = int(3)    # y will be 3
z = float(3# z will be 3.0

type() function:

You can get variable type using type() function.

Example:

x = 5
y = "John"
print(type(x))
print(type(y))

Buscar
Categorías
Read More
Other
Feed Antioxidants Market Analysis and Outlook Report 2025-2034
Global Feed Antioxidants Market: Industry Trends, Share, Size, Growth, Opportunity and...
By ASHWINI GOURKHEDE 2025-05-05 04:52:52 0
Other
Laser Welding Machine Price: Factors, Comparisons & Best Value for 2024
Laser welding machines are revolutionizing industries with precision, speed, and efficiency. But...
By John Kaur 2025-05-29 06:40:44 0
Other
Digital Graphiks; A Well Recognized Logo Design Dubai
your brand’s mission, values, and vision. If you’re building or rebranding your...
By Sophia Ivy 2025-06-04 10:33:28 0
Other
Fertilizer Catalyst Market Flourishes with Focus on Soil Health Efficiency
Fertilizer Catalyst Market grows as food demand rises and focus shifts to eco-friendly, optimized...
By Lisa Tate 2025-05-22 11:15:58 0
Other
Circular Polymers Market In-Depth Analysis: Industry Outlook & Region Forecast by Fact MR
The circular polymers market is valued at USD 88.52 billion in 2025. As per Fact.MR...
By Akshay Gorde 2025-05-14 13:30:15 0