- # Integer
int_var = 42
print(“Integer:”, int_var, type(int_var))# Float
float_var = 3.14
print(“Float:”, float_var, type(float_var))# Complex
complex_var = 2 + 3j
print(“Complex:”, complex_var, type(complex_var))# Boolean
bool_var = True
print(“Boolean:”, bool_var, type(bool_var))# String
str_var = “Hello, Python!”
print(“String:”, str_var, type(str_var))# List (ordered, mutable collection)
list_var = [1, 2, 3, “Python”, 4.5]
print(“List:”, list_var, type(list_var))# Tuple (ordered, immutable collection)
tuple_var = (10, 20, 30, “Immutable”)
print(“Tuple:”, tuple_var, type(tuple_var))# Set (unordered, unique elements)
set_var = {1, 2, 3, 4, 4, 5}
print(“Set:”, set_var, type(set_var))# Dictionary (key-value pairs)
dict_var = {“name”: “Alice”, “age”: 25, “city”: “New York”}
print(“Dictionary:”, dict_var, type(dict_var))# Bytes (immutable sequence of bytes)
bytes_var = b”Hello”
print(“Bytes:”, bytes_var, type(bytes_var))# Bytearray (mutable sequence of bytes)
bytearray_var = bytearray([65, 66, 67])
print(“Bytearray:”, bytearray_var, type(bytearray_var))# Memoryview (view of a bytes-like object)
memoryview_var = memoryview(bytes_var)
print(“Memoryview:”, memoryview_var, type(memoryview_var))# NoneType (Represents null/none)
none_var = None
print(“NoneType:”, none_var, type(none_var))
Leave a Reply