×

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

Zoeken
Categorieën
Read More
Health
New Range of Kits for Advanced Exosome Labeling & Purification
CD Bioparticles, a leading manufacturer and supplier of numerous drug delivery products and...
By Richard Gray 2025-05-28 03:34:59 0
Other
Lead Generation in 2025: Strategies That Deliver Results
Introduction In the dynamic world of B2B marketing, lead generation remains a...
By Robert Haas 2025-06-04 11:35:44 0
Other
食品グレードのセルロース濾過助剤市場調査2025:規模シェア、最新動向、産業分析、成長機会
2025年6月3日に、YH Research株式会社(本社:東京都中央区)は、調査レポート「グローバル食品グレードのセルロース濾過助剤のトップ会社の市場シェアおよびランキング...
By Krystal Lin 2025-06-03 08:18:37 0
Cars and Trucks
From Gym Class to Streetwear Royalty
From Gym Class to Streetwear Royalty Eric Emanuel transformed something as simple Erice Manuel...
By OVO Clothing 2025-06-06 05:05:09 0