Values in Python

Python has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.

# Strings, which can be added together with +
print("python" + "lang")

# Integers and floats
print("1+1 =", 1+1)
print("7.0/3.0 =", 7.0/3.0)

# Booleans, with boolean operators as you'd expect
print(True and False)
print(True or False)
print(not True)

To run the program, save it as values.py and use the Python interpreter:

$ python values.py
pythonlang
1+1 = 2
7.0/3.0 = 2.3333333333333335
False
True
False

In this example, we demonstrate various value types in Python:

  1. Strings: We concatenate two strings using the + operator.
  2. Numbers: We perform integer addition and floating-point division.
  3. Booleans: We use logical operators (and, or, not) with boolean values.

Python’s print() function is used to output the results, similar to how fmt.Println() is used in the original example.

Note that Python, being a dynamically typed language, doesn’t require explicit type declarations. The interpreter infers the types based on the values assigned or the operations performed.