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

Suche
Kategorien
Mehr lesen
Health
Tooth Strengthening: Root Canal with Crown in Islamabad
When a tooth is severely decayed, infected, or damaged, simply filling it may not be enough. To...
Von Iqra Iftikhar 2025-07-18 06:02:53 0
SEO
二硫化モリブデンベースの乾式潤滑油市場競争分析:主要企業、ランキング、投資動向2025
2025年6月27日に、QYResearch株式会社(所在地:東京都中央区)は「二硫化モリブデンベースの乾式潤滑油―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の...
Von Qyresearch Jasmine1 2025-06-27 06:53:30 0
Andere
Cholesterol Management Devices Market Revenue Analysis: Growth, Share, Value, Scope, and Insights
"Executive Summary Cholesterol Management Devices Market :  The cholesterol...
Von Shweta Kadam 2025-07-16 08:54:44 0
Andere
E-Commerce and Marketplaces Powering the Secondhand Electronics Boom
The Europe secondhand electronic products market is undergoing a transformative evolution, fueled...
Von Mayur Gunjal 2025-06-12 08:45:58 0
Andere
Global Nano & Microsatellite Market Trends, Opportunities, Current Analysis and Forecast (2024-2032) I UnivDatos
According to the UnivDatos, growing demand for high-end 3D printing with increased efficiency...
Von Ankit Rath 2025-06-12 09:16:00 0
Omaada - A global social and professionals networking platform https://www.omaada.com