×

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))

Cerca
Categorie
Leggi tutto
Altre informazioni
Costume Jewelry Market to Register 6.5% CAGR Through 2030 | Key Drivers and Opportunities
MarkNtel Advisors recently published a detailed industry analysis of the Global Costume...
By Jack Daniel 2025-06-13 12:03:39 0
Altre informazioni
Lignosulfonate Concrete Admixtures Market Grows with Increasing Sustainable Construction Practices
"Executive Summary Lignosulfonate Based Concrete Admixtures Market : Data Bridge...
By Rahul Rangwa 2025-06-18 04:45:08 0
Health
Hypertension Treatment in Jaipur: Take Control of Your Blood Pressure Today
High blood pressure, or hypertension, is often called the "silent killer" for a reason. It...
By Rahul Mathur 2025-06-26 07:23:11 0
Altre informazioni
Hydrogen Fueling Station Market Expands with Global Hydrogen Demand
Hydrogen Fueling Station Market is growing due to global infrastructure expansion and integration...
By Lisa Tate 2025-06-18 10:41:03 0
Altre informazioni
Swimming Academy Singapore
Mermaids Swim Academy – the Trusted Swimming Academy in Singapore near You Looking for a...
By Technology Welldone 2025-06-07 08:42:38 0