×

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

Căutare
Categorii
Citeste mai mult
Alte
Vein Illuminator Market Revenue and Share Study Analysis to 2034
The most recent report published by Vantage Market Research indicates that the "Vein Illuminator...
By Tushar Jane 2025-06-11 05:20:00 0
Alte
ワイヤレスパワーレシーバー調査レポート:市場規模、産業分析、最新動向、予測2025-2031
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「ワイヤレスパワーレシーバー―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年5月2...
By Moni Ka 2025-05-20 06:55:07 0
Information Technology
LEDパネルディスプレイドライバーチップの世界市場展望:規模、成長ドライバー、将来予測2025-2031
2025年5月22日に、QYResearch株式会社(所在地:東京都中央区)は「LEDパネルディスプレイドライバーチップ―グローバル市場シェアとランキング、全体の売上と需要予測、2025~203...
By Qyresearch Jasmine1 2025-05-22 07:01:57 0
Wellness
Investor Visas in the UK: Building Your Future While Boosting the Economy
The UK has long been a global hotspot for investment, attracting high-net-worth individuals from...
By King Ofmasala 2025-06-06 18:18:15 0
Alte
グローバルN-オクチルフェロセンレポート:市場シェア、需要分析、成長機会2025
2025年6月9日に、YH Research株式会社(本社:東京都中央区)は、調査レポート「グローバルN-オクチルフェロセンのトップ会社の市場シェアおよびランキング...
By Krystal Lin 2025-06-09 06:04:11 0