×

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
Categories
Read More
Information Technology
世界の高電圧ガラス釉抵抗器市場:競争環境、産業動向、成長予測2025-2031年
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「高電圧ガラス釉抵抗器―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年6月3日より...
By Qyresearch Jasmine1 2025-06-03 09:00:59 0
SEO
Essentials Hoodie fashion styling Trend
In recent years, the Essentials Hoodie has emerged as a defining piece in the world of...
By Essentials Hoodie 2025-05-22 11:28:10 0
Health
How Can I Test for Erectile Dysfunction at Home?
Erectile dysfunction (ED) is a sensitive issue for many men, but it's more common than you might...
By Jack Leo 2025-05-22 04:11:35 0
Other
Signs It’s Time to Hire a Creative Agency (And What Happens Next)
In today’s hypercompetitive market, creativity isn't just a nice-to-have—it’s a...
By Mila Scarle 2025-06-05 11:24:07 0
Networking
What is the scope of UI UX
UI (User Interface) and UX (User Experience) are two interconnected aspects of design. UI design...
By Tamizhini 915 2025-06-03 12:12:55 0