×

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

Pesquisar
Categorias
Leia Mais
Outro
Love Shayari in Hindi for Girlfriend
Best Romantic Love Shayari in Hindi for Girlfriend – Express Your Feelings with RoopVibes...
Por Technology Welldone 2025-06-07 08:35:47 0
Outro
Germany Variable Frequency Drive Market: Precision Engineering and Demand Forecast
Germany Variable Frequency Drive Market The variable frequency drive (VFD) market in Germany is...
Por Reshama Patil 2025-06-05 08:10:18 0
Outro
Europe Outpatient Surgery Market Analysis and Forecast (2025–2032)
Europe Outpatient Surgical Procedures Market size was valued at US$ 49.68 Billion in 2024 and the...
Por Indrakshi Mmr 2025-06-06 09:16:52 0
Outro
Corporate Tax Consulting Market outlook and future Growth Analysis up to 2034
The worldwide "Corporate Tax Consulting Market" 2025 Research Report presents a professional and...
Por Tushar Jane 2025-05-13 05:13:38 0
Information Technology
住宅用防水バリア (WRB)分析レポート2025:市場規模、シェア、成長率、業界動向
2025年5月23日に、QYResearch株式会社(所在地:東京都中央区)は「住宅用防水バリア...
Por Qyresearch Jasmine1 2025-05-23 09:16:29 0