---
description: I LOVE DOING THIS :)
---

# Input and Output

In Python 2, you have a built-in function `raw_input()`, whereas in Python 3, you have `input()`. The program will resume once the user presses the ENTER key.

```
>>> raw_input()
I am learning python 2
```

```
>>> input()
I am learning python 3
```

### Output using `print()` function

```
>>> print "Python 2"
Python 2

>>> print("Python 3")
Python 3
```

### More on using `print()`

```
>>> print("5"*6)
555555

>>> print(5,6,7)
5 6 7

>>> print('LOVE', 30, 82.2)
LOVE 30 82.2

>>> print('LOVE', 30, 82.2, sep=',')
'LOVE', 30, 82.2
```

By default, `print` goes to a new line at the end. You can change this by using the keyword `end`&#x20;

```
>>> print('LOVE', 30, 82.2, sep=',', end='!!\n')
'LOVE', 30, 82.2!!
```

You can change this default implementation. You can have a colon `:` between the letters instead of a new line

```
>>> for i in "python" :
       print(i, end=':')

p:y:t:h:o:n:
```

### Walrus Operator `:=`

This Operator allows you to assign values to variables within an expression

```
# Instead of this !!
>>> num = int(input())
>>> print(num)
```

```
# Use this !!
>>> print(num:=int(input()))
```

### Importing Sys for User Inputs

The **sys** module provides various functions and variables. It allows operating on the interpreter as it provides access to the variables and functions that interact strongly with the interpreter

```
>>> name = sys.argv[1]
Akash
>>> print(name)
Akash
```
