×

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

Site içinde arama yapın
Kategoriler
Read More
Other
世界の3D プリンティングパウダーハンドリングシステム市場規模2025-2031:競合状況、需要分析、成長予測
2025年6月9日に、QYResearch株式会社(所在地:東京都中央区)は「3D...
By Qyresearch Jasmine1 2025-06-09 09:02:21 0
SEO
タブレットスケールの世界調査レポート:2031年には170百万米ドルに達する見込み
2025年6月11日に、QYResearch株式会社は「タブレットスケール―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査レポートを発表しました。本報告書は、...
By Qyresearch Jasmine1 2025-06-11 03:24:59 0
Information Technology
はんだペーストの世界市場レポート:主要企業分析、競争環境、成長戦略2025
はんだペースト世界総市場規模...
By Qyresearch Jasmine1 2025-05-19 02:46:21 0
Other
Laser China Leader: Why Mart Laser Stands Out in Precision Metal Cutting Solutions
When professionals search for Laser China solutions, Mart Laser continues to be a trusted name in...
By Hanzla Ali 2025-06-10 07:48:19 0
Other
Heart Touching Love Shayari
Heart Touching Love Shayari in Hindi | Shayari for Boyfriend – RoopVibes Explore the most...
By Technology Welldone 2025-06-08 10:07:02 0