About 21,500,000 results
Open links in new tab
  1. Python Variables - W3Schools

    Variables are containers for storing data values. Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. Variables do not need to be declared with any particular type, and can even change type after they have been set.

  2. python - How can you dynamically create variables? - Stack Overflow

    Unless there is an overwhelming need to create a mess of variable names, I would just use a dictionary, where you can dynamically create the key names and associate a value to each. # dynamically create key. key = ... # calculate value. value = ... a[key] = value . k += 1.

  3. Python Variables – Complete Guide - Python Guides

    Jul 23, 2024 · In Python, variables are created when you assign a value to them using the assignment operator =. For example: In the above example, city, population, and area are variables. The variable city is assigned the string value "New York", population is assigned the integer value 8419000, and area is assigned the floating-point number 468.9.

  4. Variables in Python: Usage and Best Practices – Real Python

    Jan 12, 2025 · The primary way to create a variable in Python is to assign it a value using the assignment operator and the following syntax: In this syntax, you have the variable’s name on the left, then the assignment (=) operator, followed by the …

  5. python - How do I create variable variables? - Stack Overflow

    Use the built-in getattr function to get an attribute on an object by name. Modify the name as needed. It's not a good idea. If you are accessing a global variable you can use globals (). If you want to access a variable in the local scope you can use locals (), but you cannot assign values to the returned dict.

  6. Python Variables - GeeksforGeeks

    Mar 7, 2025 · Variables in Python are assigned values using the = operator. Python variables are dynamically typed, meaning the same variable can hold different types of values during execution. Python allows multiple variables to be assigned values in a single line.

  7. Python Variables: A Beginner's Guide to Declaring, Assigning, and ...

    Just assign a value to a variable using the = operator e.g. variable_name = value. That's it. The following creates a variable with the integer value. In the above example, we declared a variable named num and assigned an integer value 10 to it. Use the built-in print () function to display the value of a variable on the console or IDLE or REPL.

  8. Python Variable: Storing Information for Later Use

    Apr 2, 2024 · For this, we use the Python variable. In this article, you learn what a variable is and how to declare one. We’ll also look at the rules and best practices for creating variables.

  9. Python Variables – The Complete Beginner's Guide

    Mar 22, 2023 · In Python, variables are created the moment you give or assign a value to them. How Do I Assign a Value to a Variable? Assigning a value to a variable in Python is an easy process. You simply use the equal sign = as an assignment operator, followed by the value you want to assign to the variable. Here's an example:

  10. Python Variables - Python Examples

    Python is a dynamically typed programming language, which means, there is no need to specify the datatype when you are creating a variable. Also, there is no special keyword to create or define a variable. Just assign the value to the variable. The syntax of creating and assigning a variable with a value is given below.

  11. Some results have been removed
Refresh