Python Variables: Data Types and Assignments

VARIABLES AND DATATYPE 1. Variable is a name that refers to a value. It is used to store data in memory. 2. In Python, you can create a variable by simply assigning a value to it Example: x = 10 y = "Hello, World!" z = 3.14 3. Python is a dynamically typed language, which means you don't need to declare the type of a variable. The type is inferred from the value assigned to it. 4. You can change the value of a variable at any time, and it can also change its type. Example: x = 10 print(x) # Output: 10 x = "Now I'm a string!" print(x) # Output: Now I'm a string! 5. Python has several built-in data types, including: - Integer (int) - String (str) - Float (float) - Boolean (bool)

To view or add a comment, sign in

Explore content categories