×

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

Rechercher
Catégories
Lire la suite
Autre
世界のポイントツーポイントマイクロ波アンテナ市場規模2025-2031:競合状況、需要分析、成長予測
ポイントツーポイントマイクロ波アンテナ世界総市場規模...
Par Moni Ka 2025-06-04 09:36:58 0
Autre
UAE Green Hydrogen Market Outlook: Policy, Investment, and Technology Trends
UAE Green Hydrogen Market Overview: The United Arab Emirates (UAE) has emerged as a key player in...
Par Reshama Patil 2025-06-09 08:54:32 0
Autre
Medical Device Security Market Research Report 2025-2034 - Industry Insights, Trends & Competitive Outlook
The worldwide "Medical Device Security Market" 2025 Research Report presents a professional and...
Par Tushar Jane 2025-05-16 05:09:22 0
Health
Addressing Common Teeth Whitening Concerns in Riyadh’s Climate and Lifestyle
Introduction: Teeth Whitening in Riyadh’s Unique Environment Teeth whitening has gained...
Par Jack Mark 2025-05-30 20:21:07 0
Information Technology
Get Stunning Website Designs for Your Brand Today
Get stunning website designs tailored to elevate your brand with VRS Technologies. We offer...
Par VRS Technologies 2025-06-09 06:36:09 0