Today we are going to see python print statement usage.
Print is used to print the output in the console.
Printing a simple string
print("Hello, World!") # Output: Hello, World!
Printing numbers
print(123) # Output: 123
print(3.14) # Output: 3.14
Printing multiple values
print("The answer is", 42) # Output: The answer is 42
Using formatted strings (f-strings)
name = "Alice"
age = 30
print(f"My name is {name} and I am {age} years old.") # Output: My name is Alice and I am 30 years old.
Printing with different separators and end characters
print("Python", "is", "fun", sep="-") # Output: Python-is-fun
print("This is the first line.", end=" ") # Output: This is the first line. This is the second line.
print("This is the second line.")
Top comments (1)
Find more information here:
masterpy.com/lesson-01-working-in-...
Cheers!