×

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

Rechercher
Catégories
Lire la suite
Autre
Germany Generator Sales Market Insights, Trends & Forecast 2025
Germany Generator Sales Market: The generator sales market in Germany epitomizes precision...
Par Reshama Patil 2025-06-02 06:34:19 0
Autre
自動冷媒充填機市場規模予測:2031年には78.6百万米ドルに到達へ
2025年6月9日に、QYResearch株式会社は「自動冷媒充填機―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査レポートを発表しました。本報告書は、自動冷...
Par Qyresearch Jasmine1 2025-06-09 03:01:50 0
Autre
High-Performance Computing Units Market to Register 7% CAGR Through 2030 | Key Drivers and Opportunities
The High-Performance Computing Units Market size was valued at around USD 41...
Par Jack Daniel 2025-06-09 12:32:57 0
Autre
Premium Outcall Massage Services in Dubai – Relax Anytime, Anywhere
Welcome to Dubai Massage Outcall, your premier destination for luxurious and professional outcall...
Par Outcallmassage Dubai 2025-05-22 07:07:52 0