0% found this document useful (0 votes)
4 views2 pages

All Python Variable Examples

The document provides examples of basic variable types in Python, including Integer, Float, String, Boolean, List, Tuple, Dictionary, Set, and NoneType. It also demonstrates concepts such as multiple assignment, variable swapping, string concatenation with variables, and basic math operations with variables. Each example includes a variable declaration and a print statement to display the variable's value.

Uploaded by

soulayush20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

All Python Variable Examples

The document provides examples of basic variable types in Python, including Integer, Float, String, Boolean, List, Tuple, Dictionary, Set, and NoneType. It also demonstrates concepts such as multiple assignment, variable swapping, string concatenation with variables, and basic math operations with variables. Each example includes a variable declaration and a print statement to display the variable's value.

Uploaded by

soulayush20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

All Basic Variable Examples in Python

1. Integer

age = 18

print("Age:", age)

2. Float

price = 99.99

print("Price:", price)

3. String

name = "Advik Anand"

print("Name:", name)

4. Boolean

is_student = True

print("Is Student?", is_student)

5. List

subjects = ["Math", "Physics", "Chemistry"]

print("Subjects:", subjects)

6. Tuple

coordinates = (10, 20)

print("Coordinates:", coordinates)

7. Dictionary

student = {

"name": "Advik",

"class": 12,

"age": 18

print("Student Info:", student)

8. Set
unique_numbers = {1, 2, 3, 2, 1}

print("Unique Numbers:", unique_numbers)

9. NoneType

data = None

print("Data:", data)

10. Multiple Assignment

x, y, z = 10, 20, 30

print(x, y, z)

11. Variable Swapping

a = 5

b = 10

a, b = b, a

print("a:", a, "b:", b)

12. String + Variable

name = "Advik"

age = 18

print(f"My name is {name} and I am {age} years old.")

13. Math with Variables

a = 8

b = 2

print("Add:", a + b)

print("Divide:", a / b)

print("Power:", a ** b)

You might also like