Skip to content

Commit 165328e

Browse files
committed
[Add]: Print Function
1 parent d621146 commit 165328e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/python-basics/print-function.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Print Function
6+
7+
The print function in Python is used to display messages on the console. You can pass any value to it, and it will convert it to a string and print it. If you want to print multiple items, you can separate them with commas. By default, there is no separator, but you can add one using the sep argument. Additionally, each print statement ends with a new line, but you can change this using the end argument.
8+
9+
## Examples
10+
11+
### Basic Print:
12+
13+
```python
14+
print("Welcome to Python!")
15+
```
16+
17+
### Multiple Elements with Default Separator:
18+
19+
```python
20+
print("Python", "is", "fun")
21+
```
22+
23+
Output: Pythonisfun
24+
25+
### Using a Custom Separator:
26+
27+
```python
28+
print("Python", "is", "fun", sep=" ")
29+
```
30+
31+
Output: Python is fun
32+
33+
### Changing the End Character:
34+
35+
```python
36+
print("Hello", end="-")
37+
print("World")
38+
```
39+
40+
Output: Hello-World
41+
42+
### Combining Both sep and end:
43+
44+
```python
45+
print("Learn", "Python", sep="\*", end="!")
46+
print("It's great")
47+
```
48+
49+
Output: Learn\*Python!It's great
50+
51+
These examples should help you understand how to use the print function effectively.

0 commit comments

Comments
 (0)