×

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

Buscar
Categorías
Read More
Electric
Crowning Rebellion: The Loverboy Hat as a Symbol of Queer Power and Playful Protest
Fashion has always had its revolutionaries. Those rare visionaries who do not simply dress bodies...
By Vertabraec Vertabraec 2025-05-29 20:53:32 0
Shopping
Keep Your 4WD Running Smoothly with Valvoline Transfer Case Fluid
When it comes to maintaining your four-wheel-drive (4WD) or all-wheel-drive (AWD) vehicle, one...
By Jen Diesi 2025-06-02 15:34:39 0
Information Technology
Fast Broadband Now: Unleash High-Speed Connectivity with Premier Cable Internet Services
In the digital age, a reliable and fast internet connection is essential for streaming,...
By James Anderson 2025-06-05 11:31:44 0
Other
Dental Imaging Market Analysis and Growth Opportunities 2025-2034 Forecast
The most recent report published by Vantage Market Research indicates that the "Dental Imaging...
By Tushar Jane 2025-05-28 05:15:23 0
Art
Can a metallic colored pencil actually shine like real metal on regular paper?
When you first hear the term metallic colored pencil, it might sound like just another crayon...
By Hanzla Ali 2025-05-22 05:01:41 0