×

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
Information Technology
Key Metrics To Choose the Right Transport Management Software
In a world where speed and efficiency define logistics success, choosing the right Transport...
Von Leo Parker 2025-05-19 13:02:49 0
Health
A Guide to Tapering Off Xanax Effectively
Xanax Online Pills is based upon this timeline, the physicians generally will reduce the dose by...
Von Hennry Lauren 2025-05-06 11:27:45 0
Other
マイクロDCモーター業界レポート:市場動向、機会分析、将来予測2025-2031
マイクロDCモーター世界総市場規模...
Von Moni Ka 2025-06-04 09:45:58 0
Other
Small Gas Engines Market: Precision Engineering Meets Utility Demand
Small Gas Engines Market Demand: The demand for small gas engines continues to exhibit resilience...
Von Reshama Patil 2025-06-06 06:34:58 0
Other
Business-To-Business (B2B) E-Commerce Market Research Report: Growth, Share, Value, Trends, and Insights
The most recent report published by Vantage Market Research indicates that the...
Von Tushar Jane 2025-05-16 05:09:02 0