×

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

Поиск
Категории
Больше
Другое
Organic Fertilizer Granulators Market In-Depth Analysis: Industry Outlook & Region Forecast by Fact MR
The global organic fertilizer granulators market is valued at US$ 874 million and is...
От Akshay Gorde 2025-05-20 13:51:57 0
Crafts
Качественные дипломы для вашего успеха!
Где купить диплом с реестром. В современном мире все больше людей задумываются о том, как быстро...
От Worksale Worksale 2025-05-28 11:28:17 0
Другое
Germany Synchronous Condenser Market: Enhancing Grid Reliability in Energy Transition
Germany Synchronous Condenser Market The Germany synchronous condenser market has been...
От Reshama Patil 2025-06-06 06:31:22 0
Другое
Leap Engine Market: Trends, Share, Opportunities Current Analysis and Forecast (2024-2032) I UnivDatos
The LEAP Engine market, which forms an integral part of today’s aircraft engine propulsion...
От Ankit Rath 2025-06-04 12:09:12 0
Другое
In-Dash Navigation System Market Research Report: Growth, Share, Value, Trends, and Insights
The most recent report published by Vantage Market Research indicates that the "In-Dash...
От ASHWINI GOURKHEDE 2025-05-23 05:46:33 0