×

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

Поиск
Категории
Больше
Другое
Celebrate Indian Culture in Style: Discover the Magic of Indiclub.shop
In a world that’s moving fast toward global minimalism, Indiclub.shop is proudly bringing...
От Indiclub Shop 2025-06-02 12:13:00 0
Другое
Warum ein Laser Rostentferner die beste Wahl für Ihre Werkstatt ist
Rost ist ein hartnäckiger Gegner, der Metalloberflächen langsam zerstört....
От John Kaur 2025-06-10 10:12:31 0
Information Technology
A Complete Guide to WooCommerce Quick View Pro
In the fast-paced world of online shopping, users expect a seamless experience that minimizes...
От Franklin Clinton 2025-05-20 12:29:53 0
Главная
Electric vs. Manual Recliners: What’s the Right Choice for You?
A recliner isn't just a piece of furniture—it's a commitment to comfort. Whether...
От Wooden Street 2025-05-28 09:01:48 0
Другое
Subsea System Market: Domestic Demand and Export Opportunities in Focus
Subsea System Market Demand The demand for subsea systems is driven by the need for advanced...
От Reshama Patil 2025-06-05 07:51:55 0