Python Syntax

You can execute Python code in Windows Command Line or within a Jupyter Notebook cell:

print("Hello, World!")
Hello, World!
Python Indentation

Python uses indentation to define blocks of code:

if 5 > 2:
    print("Five is greater than two!")
Five is greater than two!
Comments in Python

Python comments starts with #, and Python ignores them:

print("Hakuna Matata!") # This is a comment
Hakuna Matata!
Formatted String Literal (f-string)

A formatted string literal or f-string, is a way to format strings in Python. It allows you to embed expressions, including variables, directly inside a string, making string interpolation simpler and more readable.

name = "Diana Bishop"
print(f"Her name is {name}.")
Her name is Diana Bishop.

Previous     Next

Use the Search Bar to find content on MarketingMind.