×

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

Search
Nach Verein filtern
Read More
Information Technology
Secure Your Business with MS Office 365 Services in Riyadh
Secure your business operations with top-notch MS Office 365 Services in Riyadh from VRS...
Von VRS Technologies 2025-06-10 04:01:25 0
Information Technology
玉虫色塗料市場調査2025-2031:シェア、産業分析、最新動向、成長機会
2025年5月8日に、QYResearch株式会社(所在地:東京都中央区)は「玉虫色塗料―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の最新調査資料を発行しました...
Von Qyresearch Jasmine1 2025-05-08 05:38:33 0
Other
手持ち基準温度計調査レポート:市場規模、産業分析、最新動向、予測2025-2031
2025年6月9日に、QYResearch株式会社(所在地:東京都中央区)は、「手持ち基準温度計―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査資料を発行しま...
Von Xu Shuyun 2025-06-09 03:38:14 0
Other
North America Rocking Chairs and Adirondack Chairs Market Outlook: Innovations and Opportunities to 2030
The North America rocking chairs and Adirondack chairs market, valued at US$ 1.6 billion in 2022,...
Von Mayur Gunjal 2025-06-06 05:58:33 0
Other
AI Training Dataset Market Revenue and Share Study Analysis to 2034
The most recent report published by Vantage Market Research indicates that the "AI Training...
Von Tushar Jane 2025-05-21 05:16:45 0