voidex/20-29 Areas/20 Programming/20.01 Python/print().md

31 lines
697 B
Markdown

---
title: print()
tags:
- python
- functions
- output
aliases:
- print
- print-statement
- output-text
---
> [!note] Concept
> The `print()` function outputs a message (usually a string) to the screen.
>
> > [!example] Example
> > ```python
> > print('Hello, world!')
> > print('What is your name?') # ask for name
> > print() # Blank Output
> > ```
>
> > [!important] Best Practices
> > - Use `print()` to confirm variable values or trace execution during debugging.
> > - Add comments to describe the purpose of each printed message where helpful.
> > For formatted strings, prefer:
> > ```python
> > name = "Alice"
> > print(f"Hello, {name}!")
> > ```