×

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
Care Management Solutions Market Booming in Size in 2025
The most recent report published by Vantage Market Research indicates that the "Care Management...
By Tushar Jane 2025-05-27 05:13:49 0
Information Technology
産業用CNC電動線材曲げ機市場競争分析:主要企業、ランキング、投資動向2025
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「産業用CNC電動線材曲げ機―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年5月1...
By Qyresearch Jasmine1 2025-05-15 06:39:46 0
Other
Hole Opener Market Unveiling Driving Factors, Strategies, and Forecasted Trends by Fact MR
The global hole opener market is expected to reach USD 3.4 billion by 2035, up from USD...
By Akshay Gorde 2025-06-03 13:42:15 0
Other
Achieving Your UK Student Visa Dreams with Immigration Solicitors4me: Expert Immigration Solicitors
The UK Student Visa is a gateway for international students to access world-class education at...
By Immigration Solicitors 2025-05-05 18:41:05 0
Other
鉱山用粉砕媒体市場規模予測:2031年には10500百万米ドルに到達へ
2025年6月6日に、QYResearch株式会社(所在地:東京都中央区)は、「鉱山用粉砕媒体―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の最新調査資料を公開し...
By Qyresearch Jasmine1 2025-06-06 06:07:38 0