Run Program ❯
Python Home
❯
Run Code
Change Orientation
# Variables to print name = "Alice" age = 30 score = 95.5 # 1. Print single variable print(name) # 2. Print multiple variables separated by commas (adds space automatically) print(name, age, score) # 3. Print with string concatenation (convert non-string to string) print("Name: " + name + ", Age: " + str(age) + ", Score: " + str(score)) # 4. Print using old-style string formatting (% operator) print("Name: %s, Age: %d, Score: %.1f" % (name, age, score)) # 5. Print using str.format() method print("Name: {}, Age: {}, Score: {:.1f}".format(name, age, score)) # 6. Print using f-strings (Python 3.6+) print(f"Name: {name}, Age: {age}, Score: {score:.1f}") # 7. Print variables with custom separator and end print(name, age, score, sep=" | ", end=" <-- End of output\n") # 8. Print with escape characters print("Name:\t", name) print("Age:\n", age)