print in python code example

Example 1: print in python

print("hello world")

Example 2: print in python

print("the sentence you want to print")

Example 3: print in python

print("Hey! How are you doing?")

## formatted string literal
answer = "Well!"
print(f"Hey! How are you doing? {answer}")

Example 4: print in python

# Simple Print:
print("Hello World!")

# Formatting message in python3.6- :
name = "World"
print("Hello {}!".format(name))

# Formatting message in python3.7+ :
name = "World"
print(f"Hello {name}!")

Example 5: print in python

print("Text")

Example 6: print in python

# Print statements in python

# A usual print() statement looks like this:

print("Hello from the print statement!")

#   A print statement starts with print( , as it is a built-in function

# It contains any given value that can be printed to the console. (ex. "Hello!")

# It ends with a closed bracket

# A few more examples:


name = input("Enter a name :\n") # asks for a name
print(f"Your name is {name}") # Your name is <whatever name you entered>

print(1 + 2) # 3

print(not True and not False) # False

Example 7: print in python

# the print commmand will write anything in your out put box
print("hello world")

Example 8: print in python

words = 'Hello', 'World', 'Python', 'makes', 'life', 'easier'
print(*words, sep='\n')

Example 9: print in python

a = 5
print('The value of a is', a)

Example 10: print in python

print('lol')