# Input

{% embed url="<https://docs.google.com/presentation/d/1WgJ4b9_3h2oQsJ3jjxh76G51pu-iaXkPy-KU3lSxAwc/edit?usp=sharing>" %}

## Introduction

Typically, programs take input from a user, process this input and give the user output.

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-LVZfL3jJAyGUZRrA70W%2F-LVZftDEj76s8O5GjyDD%2FScreen%20Shot%202019-01-06%20at%202.41.36%20PM.png?alt=media\&token=a70c21e7-dbac-4d24-81da-a6b3117b1da7)

## input function

The input() function takes input from your console. It reads the input and converts it to a string.

## Variable Roles

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-Ld0uYKREk0E6ifyBsEC%2F-Ld0udJ_c-fcYtF88LSU%2FScreen%20Shot%202019-04-21%20at%206.00.18%20PM.png?alt=media\&token=2f07f258-e9b6-4b0e-85a2-ba207760938b)

## Changing the data type of the input

| Function | Converts               | Example                                  |
| -------- | ---------------------- | ---------------------------------------- |
| int()    | converts to an integer | num = int(input("Give me an integer: ")) |
| float()  | converts to a float    | num = float(input("Give me a float: "))  |

{% hint style="info" %}
When using the input function, think about about what data type you want.
{% endhint %}

```python
name = input("What's your name? ")
num = int(input("Give me a number: "))
money = float(input("How much money do you have? "))
```

{% hint style="danger" %}
A common mistake is not matching the number of open parenthesis and closed parenthesis.
{% endhint %}

## Example

Write a program that prompts for two numbers. Print the sum, difference, product, and quotient of those numbers.  In addition, print the result of integer division and the modulus operator of those numbers.

{% code title="example1.py" %}

```python
num1 = int(input("Number 1: "))
num2 = int(input("Number 2: "))
print("Sum:", num1 + num2)
print("Difference:", num1 - num2)
print("Product:", num1 * num2)
print("Quotient:", num1 / num2)
print("Integer Division:", num1 // num2)
print("The Remainder of num1 divided by num2:", num1 % num2) 
```

{% endcode %}
