Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions .ipynb_checkpoints/Advanced_IO-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Some Indepth concepts on I/O:\n",
"I/O - Input/Output.\n",
"Input and Output are integral part of a program. This makes the program interactive (dynamic) and user friendly.\n",
"\n",
"Input conditions and values may vary depending on situation / constraints. So handling Inputs is important.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Variations:\n",
"1. One line Input of multiple values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1. One line input:\n",
"Multiple values can be given in one line as input which needs to be processed differently. This brings in the need for a method to work with them.\n",
"\n",
"1. fixed type input\n",
"2. variable length input\n",
"\n",
"Generally one line input uses multiple assignment by splitting the values down (or scattering) to the required variables. \n",
"*map* functions are used to assign a function or change the data type of the variables."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 1. Fixed type:\n",
"In this type, the number of inputs in the line is fixed and known. A simple input statements has the required no. of variables in the LHS and input command with string splitting on the RHS.\n",
"\n",
"#### 2. Variable length type\n",
"In this type, the number of inputs in the line is variable and only minimum count is known. A simple input statements has the required no. of variables with last variable working as gather variable (with * before its name) in the LHS and input command with string splitting on the RHS."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
" Hi Hello\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hi\n",
"Hello\n"
]
}
],
"source": [
"# Example for two inputs\n",
"a, b = input().split()\n",
"print(a)\n",
"print(b)\n",
"# input: Hi Hello"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
" 10 20\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n",
"<class 'int'>\n",
"20\n",
"<class 'int'>\n"
]
}
],
"source": [
"# Change type for input\n",
"c, d = map(int, input().split())\n",
"print(c, type(c), sep = '\\n')\n",
"print(d, type(d), sep = '\\n')\n",
"# Input: 10 20"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
13 changes: 3 additions & 10 deletions .ipynb_checkpoints/DS_Lists-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@
"Use for or while loop to access element or list.\n",
"\n",
"### 2. Using * :\n",
"Using * will convert the list into a variable length arguement ($*arg$) of print method"
"Using * will convert the elements of the list into arguements of print method"
]
},
{
Expand Down Expand Up @@ -1863,8 +1863,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. List Multiplication:\n",
"String multiplication results a string with repitition. It can be done using ' * ' operator."
"### 3. List Multiplication:\n",
"List multiplication results a list with repitition. It can be done using ' * ' operator."
]
},
{
Expand Down Expand Up @@ -1896,13 +1896,6 @@
"l4 = ['Namaste ', 'Hello']\n",
"l4*5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading