×

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
Health
How Zinc Boost Hair Growth and Prevents Hair Loss?
Healthy, vibrant hair is often a sign of good overall health and balanced nutrition. Zinc is...
Von William Heil 2025-05-22 07:08:43 0
Other
Latin America Inflight Services Market Analysis and Growth Opportunities 2025-2034 Forecast
Global Latin America Inflight Services Market: Industry Trends, Share, Size, Growth,...
Von Tushar Jane 2025-05-07 05:32:50 0
Other
Reliable Airport Limo Transport – Luxury Rides for Every Flight
Traveling from the airport or traveling can be stressful, especially when you are at a tight...
Von Hayyat Limo 2025-05-21 09:05:47 0
Information Technology
電子顕微鏡用ターボ分子ポンプの世界市場規模:全体売上と需要分析予測2025~2031
2025年5月23日に、QYResearch株式会社(所在地:東京都中央区)は「電子顕微鏡用ターボ分子ポンプ―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の最新調...
Von Qyresearch Jasmine1 2025-05-23 09:11:22 0
Film
Neonatal Ventilator Market In-Depth Analysis: Industry Outlook & Region Forecast by Fact MR
The neonatal ventilator market is experiencing significant growth, driven by advancements in...
Von Akshay Gorde 2025-05-14 13:12:51 0