Subsets of elements

  • For lists and other indexable elements, you can easily find subsets:

In [18]:
x = range(1, 20)
y = "The quick brown fox jumps over the lazy dog."
# print elements 2 to 4
print(x[2:5])
print(y[2:5])
# Print every third element starting from the first element
print(x[::3])
print(y[::3])

# Print the second last element
print(x[-2])
print(y[-2])


range(3, 6)
e q
range(1, 20, 3)
T i o xusv ea g
18
g

Libraries

  • Python comes with batteries included.
  • Several commonly used things are available in standard libraries.
  • Size and breadth are large
  • Not all of them have the same quality, but most of them are great.
  • Hundreds of modules tested, ready to use.

Standard Libraries

  • Text processing string, re, textwrap
  • Numbers decimal, random
  • File system os, glob, shutil, stringIO
  • Building Applications argparse
  • Runtime features sys
  • Several others are there including networks, cryptography etc.

String

  • String utilities for a lot of common things
  • capitalize, capitalize first letters etc.
  • Have to import string module
  • Some examples:

In [19]:
import string
s = 'the quick brown fox jumps over the lazy dog.'
s.capitalize()


Out[19]:
'The quick brown fox jumps over the lazy dog.'

In [26]:
s = "The quick brown fox jumps over the lazy dog."
string.capwords(s)


Out[26]:
'The Quick Brown Fox Jumps Over The Lazy Dog.'

Example: Phonecode

  • Convert letters to numbers as seen on phones
  • Phone letters: 2 → ABC, 3 → DEF … 9 → WXYZ
  • For instance, BUYME is 28963

In [27]:
phonecode_lower = str.maketrans(string.ascii_lowercase, '22233344455566677778889999')
phonecode_upper = str.maketrans(string.ascii_uppercase, '22233344455566677778889999')
s.translate(phonecode_lower)


Out[27]:
'T43 78425 27696 369 58677 6837 843 5299 364.'

Exercise

How would you convert both upper and lowercase to phonecode?


In [ ]:

textwrap

  • Useful for pretty printing paragraphs
  • Wrapping is provided automatically

In [36]:
import textwrap
sample_text="This is a really long rambling sentence with no end in sight. This sentence is going to put people to sleep"
textwrap.fill(sample_text,width=10)
print(textwrap.fill(sample_text,width=10))
print()
print(textwrap.fill(sample_text,width=50))


This is a
really
long
rambling
sentence
with no
end in
sight.
This
sentence
is going
to put
people to
sleep

This is a really long rambling sentence with no
end in sight. This sentence is going to put people
to sleep

Decimal

  • Module for arbitrary precision arithmetic of floating point

In [37]:
print(0.1-0.00000001)
print(0.1-0.000000001)
print(0.1-0.0000000001)


0.09999999000000001
0.099999999
0.09999999990000001

With decimal


In [51]:
import decimal
a=(0,(1,0),-2)
b=(0,(1,0),-9)
type(a)


Out[51]:
tuple
  • Construct a tuple with sign, digits and exponent

In [52]:
ad = decimal.Decimal(a)
bd = decimal.Decimal(b)
type(ad)
ad - bd


Out[52]:
Decimal('0.099999990')

Contexts, Setting precision


In [55]:
from decimal import *
print(getcontext())
getcontext().prec=20
cd = decimal.Decimal((0,(3,0),-1))
print(1/cd)
getcontext().prec=40
print(1/cd)
print(1/cd+1/cd)
print(1/cd+1/cd*3)
print(1/cd+1)
#print(1/cd+1.0)


Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[InvalidOperation, DivisionByZero, Overflow])
0.33333333333333333333
0.3333333333333333333333333333333333333333
0.6666666666666666666666666666666666666666
1.333333333333333333333333333333333333333
1.333333333333333333333333333333333333333

Setting precision locally


In [56]:
with decimal.localcontext() as c:
   c.prec=2
   print(decimal.Decimal('3.1415')/3)
   print('Local Precision:', c.prec)
print('Default precision:',decimal.getcontext().prec)
print(decimal.Decimal('3.1415')/3)


1.0
Local Precision: 2
Default precision: 40
1.047166666666666666666666666666666666667
  • c has a local context. Changes to c is not propagated to rest of code.
  • Can set several contexts within same code

Per-instance context

  • Variables can also carry contexts with them.
  • Operations with the variable will have that context
  • Mixing two contexts, with two different precisions, will give higher precision of the two

In [57]:
import decimal
c = decimal.getcontext().copy()
c.prec = 3
pi = c.create_decimal('3.1415')
print('PI:', pi)
print('RESULT:', decimal.Decimal('2.01') * pi)


PI: 3.14
RESULT: 6.3114

Fractions

  • See fraction module also
  • Numerator, denominator combination
  • All operations are done with numerator, denominator
  • Can convert fractions to floats and vice versa

Random


In [78]:
import random
for i in range(5):
    print(random.random())


0.375986267407762
0.9822428719391535
0.38350504617783177
0.5204510064900055
0.9695754537075303
  • Repeat once more

In [79]:
for i in range(5):
    print(random.random())


0.3826451857969857
0.0925560235163857
0.6164335402984279
0.9277889298403925
0.6115379823420043
  • You get different values
  • For uniform random numbers:

In [76]:
for i in range(5):
    print(random.uniform(1,100))


66.17157363319582
72.20459802681887
10.729644905406404
22.906417534384897
58.7214199147031

Setting seeds

  • Sometimes you want to repeat experiments
  • Set a seed and use it for debug/design phase
  • Remove seed and deploy

In [86]:
random.seed(1)
for i in range(5):
   print(random.uniform(1,100))


14.30206016712772
84.89593995678604
76.6136872786848
26.251833548202747
50.04807362210215
  • Run it again?

Random Integers


In [102]:
for i in range(3):
    print(random.randint(1, 100))
print('\n[-5, 5]:', end="")
for i in range(3):
    print(random.randint(-5, 5))
print()


63
94
4

[-5, 5]:2
-5
-1

Random elements from a range


In [107]:
import random
for i in range(3):
    print(random.randrange(0, 101, 5))


85
35
60
  • randrange supports a step argument
  • More efficient because range is not fully constructed

Picking random items


In [109]:
import random
import itertools
outcomes = { 'heads':0, 'tails':0,}
sides = list(outcomes.keys())

for i in range(10000):
     outcomes[ random.choice(sides) ] += 1
print('Heads:', outcomes['heads'])
print('Tails:', outcomes['tails'])


Heads: 4980
Tails: 5020
  • choice() selects randomly from a sequence

Sampling

  • Sampling from a population
  • sample() function generates samples without repeating values
  • Does not modify input sequence

In [114]:
import random
with open('/usr/share/dict/words', 'rt') as f:
   words = f.readlines()
words = [ w.rstrip() for w in words ]
for w in random.sample(words, 5):
    print(w)


mismanage
Alexander
unbeknown
poets
fatheads

math library

  • math has several mathematical functions
  • whatever you expect from a math library
  • Take a look!

File System

  • Python has several tools to work with files
  • Common operations like looking at file contents, building filenames, parsing file names, traversing directories
  • Filenames are represented as simple strings
  • Strings can be built from platform independent components in os.path
    • For example, to deal with / in Unix vs. \ in Windows

os.path

  • Platform independent operations for file manipulation
  • Even if you are not planning to port your application to another platform, use os.path

Parsing Paths

  • os.sep —The separator between portions of the path (e.g., “ / ” or “ \ ”).
  • os.extsep —The separator between a filename and the file “extension” (e.g.,“ . ”).
  • os.pardir —The path component that means traverse the directory tree up one level (e.g., “ .. ”).
  • os.curdir —The path component that refers to the current directory (e.g., “ . ”).

os.path.split

  • split() breaks the path into two separate parts
  • returns a tuple

In [56]:
import os.path
for path in [ '/one/two/three',  '/one/two/three/',
    '/',  '.',
    '']:
        print('%15s : %s' % (path, os.path.split(path)))


 /one/two/three : ('/one/two', 'three')
/one/two/three/ : ('/one/two/three', '')
              / : ('/', '')
              . : ('', '.')
                : ('', '')

os.path.splitext and os.path.commonprefix

  • os.path.splitext() splits on ext
  • gives filename and extension separately
  • os.path.commonprefix() gives common prefix of paths passed as argument
  • Example:

In [57]:
paths=["/one/two/three","/one/two", "/one/two/three/a.txt"]
os.path.commonprefix(paths)


Out[57]:
'/one/two'

Building Paths

  • To combine several path components, use join()
  • If any argument to join() begins with os.sep, all previous arguments are discarded
  • New one becomes the beginning of return value

In [59]:
import os.path
for parts in [ ('one', 'two', 'three'), ('/', 'one', 'two', 'three'),
               ('/one', '/two', '/three'),
]:
    print(parts, ':', os.path.join(*parts))


('one', 'two', 'three') : one/two/three
('/', 'one', 'two', 'three') : /one/two/three
('/one', '/two', '/three') : /three

Normalizing Paths

  • Strings from different joins can end up with - /one/two//three/four - /one/./two/three/./four
  • Normalization removes these cases
  • os.path.normpath(path)
  • Try on
    • one/../two/three
    • one/./two/three
    • one//two//./three

Traversing a Directory

  • os.walk(top, func, arg)
  • Walks from the top directory to each of the subdirectories

In [118]:
import os
if not os.path.exists('example'):
    os.mkdir('example')
if not os.path.exists('example/one'):
    os.mkdir('example/one')
with open('example/one/file.txt', 'wt') as f:
    f.write('contents')
with open('example/two.txt', 'wt') as f:
    f.write('contents')
for root,dirs,files in os.walk('example'):
    print(root, dirs, files)


example ['one'] ['two.txt']
example/one [] ['file2.txt', 'file.txt']

glob

  • To find filenames which match a pattern
  • Packs a lot of power
  • Can use to find files that have a certain extension, prefix or some pattern in the middle
  • DO NOT write custom code

In [124]:
import glob
for name in glob.glob('example/*'):
     print(name)


example/two.txt
example/one
  • Prints all the contents of example directory
  • Does not recurse
  • To list contents of a subdirectory, pattern must be listed

In [74]:
for name in glob.glob('example/*w*.txt'):
    print(name)


example/two.txt

shutil

  • Useful for high level file operations
    • Copy files
    • Set permissions etc.
  • import shutil
  • Some important ones:
    • copy(), copy2(), copytree(), rmtree(), stat(), make_archive()

sys

  • Probe or change the configuration of the Python interpreter
  • Interact with the environment

In [76]:
import sys

print(sys.version)
print(sys.platform)
print(sys.flags)


3.5.2+ (default, Aug  5 2016, 08:07:14) 
[GCC 6.1.1 20160724]
linux
sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)

Runtime Environment with sys

  • sys.argv
  • Example:

In [125]:
import sys
print(sys.argv)


['/home/kumar/.local/lib/python3.5/site-packages/ipykernel/__main__.py', '-f', '/run/user/1000/jupyter/kernel-96e3a7ca-f2a2-49d0-bd4d-d3b0a0dfd132.json']
  • Save the contents in "sysargs.py"
  • Then run
    • python sysargs.py
    • python sysargs.py -l
    • python sysargs -l -a

Input and Output Streams

  • Following Unix philosophy, can access stdin, stdout and stderr

In [126]:
import sys
print('STATUS: Reading from stdin', file=sys.stderr)
data = sys.stdin.read()
print('STATUS: Writing data to stdout', file=sys.stderr)
sys.stdout.write(data)
sys.stdout.flush()
print('STATUS: Done', file=sys.stderr)


STATUS: Reading from stdin
STATUS: Writing data to stdout
STATUS: Done

Exit Code

  • Convention that a program exits with 0 as error code on clean exit
  • Non-zero for other exits
  • Example: Write a program that expects a number less than 5 as input

In [ ]:
import sys
num = int(sys.argv[1]);
if(num<5):
    sys.exit(0);
else:
    sys.exit(1);

Memory Management

  • sys.getrefcount()
  • sys.getsizeof()

Refcount

  • Python references to an object are counted
  • Object is deleted automatically if refcount hits 0

In [79]:
import sys
one = []
print('At start         :', sys.getrefcount(one))
two = one
print('Second reference :', sys.getrefcount(one))
del two
print('After del        :', sys.getrefcount(one))


At start         : 2
Second reference : 3
After del        : 2

Object Sizes


In [80]:
import sys

for obj in [ [], (), {}, 'c', 'string', 1, 2.3,
         ]:
    print('%10s : %s' % (type(obj).__name__, sys.getsizeof(obj)))


      list : 64
     tuple : 48
      dict : 288
       str : 50
       str : 55
       int : 28
     float : 24
  • Caution: Reporting size of a custom class does not include size of the attributes

sizeof Attributes


In [82]:
import sys
class myClass(object):
     def __init__(self):
         self.a='a';
         self.b=int(120)
         self.c=float(10.5)

myInst = myClass()
myInst.__dict__.values()

print(sum(sys.getsizeof(v) for v in myInst.__dict__.values()))


102

Exercise

  • Should write __sizeof__ so that it adds up
  • Get size of the custom class that we wrote before
  • Use object.__sizeof__(self) to get size of the object class. sys.getsizeof(myInst) should work

Ints and Floats

  • sys.maxint
  • sys.maxsize
  • sys.float_info.* - Has several important constants related to floating point values - Stuff usually found in float.h

Modules

  • sys.modules.keys() - All the modules included so far, changes dynamically
  • sys.builtin_module_names - All builtin modules
  • sys.path - Path of the modules

URL Library

  • urllib
    • Provides powerful methods for accessing URLs

Example

  • Let us get class web page and some relevant information from Madhu Belur's course page

In [86]:
from urllib.request import urlopen

response = urlopen("http://www.ee.iitb.ac.in/~belur/sdes")
print(response)
print(response.headers)
print(response.headers['Date'])
print(response.info())
text = response.readlines()
print(text)


<http.client.HTTPResponse object at 0x7fe6a9bbf5c0>
Date: Fri, 19 Aug 2016 10:44:06 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 02 Aug 2016 08:25:50 GMT
ETag: "56600b5-4047-5391276dddf80"
Accept-Ranges: bytes
Content-Length: 16455
Connection: close
Content-Type: text/html; charset=UTF-8


Fri, 19 Aug 2016 10:44:06 GMT
Date: Fri, 19 Aug 2016 10:44:06 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 02 Aug 2016 08:25:50 GMT
ETag: "56600b5-4047-5391276dddf80"
Accept-Ranges: bytes
Content-Length: 16455
Connection: close
Content-Type: text/html; charset=UTF-8


[b'<?xml version="1.0" encoding="utf-8" ?>\n', b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n', b'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n', b'<head>\n', b'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n', b'<meta name="generator" content="Docutils 0.11: http://docutils.sourceforge.net/" />\n', b'<title>Homepage of AE663/AE425: Software Development Techniques in Engineering and Science</title>\n', b'<style type="text/css">\n', b'\n', b'/*\n', b':Author: David Goodger (goodger@python.org)\n', b':Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $\n', b':Copyright: This stylesheet has been placed in the public domain.\n', b'\n', b'Default cascading style sheet for the HTML output of Docutils.\n', b'\n', b'See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to\n', b'customize this style sheet.\n', b'*/\n', b'\n', b'/* used to remove borders from tables and images */\n', b'.borderless, table.borderless td, table.borderless th {\n', b'  border: 0 }\n', b'\n', b'table.borderless td, table.borderless th {\n', b'  /* Override padding for "table.docutils td" with "! important".\n', b'     The right padding separates the table cells. */\n', b'  padding: 0 0.5em 0 0 ! important }\n', b'\n', b'.first {\n', b'  /* Override more specific margin styles with "! important". */\n', b'  margin-top: 0 ! important }\n', b'\n', b'.last, .with-subtitle {\n', b'  margin-bottom: 0 ! important }\n', b'\n', b'.hidden {\n', b'  display: none }\n', b'\n', b'a.toc-backref {\n', b'  text-decoration: none ;\n', b'  color: black }\n', b'\n', b'blockquote.epigraph {\n', b'  margin: 2em 5em ; }\n', b'\n', b'dl.docutils dd {\n', b'  margin-bottom: 0.5em }\n', b'\n', b'object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {\n', b'  overflow: hidden;\n', b'}\n', b'\n', b'/* Uncomment (and remove this text!) to get bold-faced definition list terms\n', b'dl.docutils dt {\n', b'  font-weight: bold }\n', b'*/\n', b'\n', b'div.abstract {\n', b'  margin: 2em 5em }\n', b'\n', b'div.abstract p.topic-title {\n', b'  font-weight: bold ;\n', b'  text-align: center }\n', b'\n', b'div.admonition, div.attention, div.caution, div.danger, div.error,\n', b'div.hint, div.important, div.note, div.tip, div.warning {\n', b'  margin: 2em ;\n', b'  border: medium outset ;\n', b'  padding: 1em }\n', b'\n', b'div.admonition p.admonition-title, div.hint p.admonition-title,\n', b'div.important p.admonition-title, div.note p.admonition-title,\n', b'div.tip p.admonition-title {\n', b'  font-weight: bold ;\n', b'  font-family: sans-serif }\n', b'\n', b'div.attention p.admonition-title, div.caution p.admonition-title,\n', b'div.danger p.admonition-title, div.error p.admonition-title,\n', b'div.warning p.admonition-title, .code .error {\n', b'  color: red ;\n', b'  font-weight: bold ;\n', b'  font-family: sans-serif }\n', b'\n', b'/* Uncomment (and remove this text!) to get reduced vertical space in\n', b'   compound paragraphs.\n', b'div.compound .compound-first, div.compound .compound-middle {\n', b'  margin-bottom: 0.5em }\n', b'\n', b'div.compound .compound-last, div.compound .compound-middle {\n', b'  margin-top: 0.5em }\n', b'*/\n', b'\n', b'div.dedication {\n', b'  margin: 2em 5em ;\n', b'  text-align: center ;\n', b'  font-style: italic }\n', b'\n', b'div.dedication p.topic-title {\n', b'  font-weight: bold ;\n', b'  font-style: normal }\n', b'\n', b'div.figure {\n', b'  margin-left: 2em ;\n', b'  margin-right: 2em }\n', b'\n', b'div.footer, div.header {\n', b'  clear: both;\n', b'  font-size: smaller }\n', b'\n', b'div.line-block {\n', b'  display: block ;\n', b'  margin-top: 1em ;\n', b'  margin-bottom: 1em }\n', b'\n', b'div.line-block div.line-block {\n', b'  margin-top: 0 ;\n', b'  margin-bottom: 0 ;\n', b'  margin-left: 1.5em }\n', b'\n', b'div.sidebar {\n', b'  margin: 0 0 0.5em 1em ;\n', b'  border: medium outset ;\n', b'  padding: 1em ;\n', b'  background-color: #ffffee ;\n', b'  width: 40% ;\n', b'  float: right ;\n', b'  clear: right }\n', b'\n', b'div.sidebar p.rubric {\n', b'  font-family: sans-serif ;\n', b'  font-size: medium }\n', b'\n', b'div.system-messages {\n', b'  margin: 5em }\n', b'\n', b'div.system-messages h1 {\n', b'  color: red }\n', b'\n', b'div.system-message {\n', b'  border: medium outset ;\n', b'  padding: 1em }\n', b'\n', b'div.system-message p.system-message-title {\n', b'  color: red ;\n', b'  font-weight: bold }\n', b'\n', b'div.topic {\n', b'  margin: 2em }\n', b'\n', b'h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,\n', b'h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {\n', b'  margin-top: 0.4em }\n', b'\n', b'h1.title {\n', b'  text-align: center }\n', b'\n', b'h2.subtitle {\n', b'  text-align: center }\n', b'\n', b'hr.docutils {\n', b'  width: 75% }\n', b'\n', b'img.align-left, .figure.align-left, object.align-left {\n', b'  clear: left ;\n', b'  float: left ;\n', b'  margin-right: 1em }\n', b'\n', b'img.align-right, .figure.align-right, object.align-right {\n', b'  clear: right ;\n', b'  float: right ;\n', b'  margin-left: 1em }\n', b'\n', b'img.align-center, .figure.align-center, object.align-center {\n', b'  display: block;\n', b'  margin-left: auto;\n', b'  margin-right: auto;\n', b'}\n', b'\n', b'.align-left {\n', b'  text-align: left }\n', b'\n', b'.align-center {\n', b'  clear: both ;\n', b'  text-align: center }\n', b'\n', b'.align-right {\n', b'  text-align: right }\n', b'\n', b'/* reset inner alignment in figures */\n', b'div.align-right {\n', b'  text-align: inherit }\n', b'\n', b'/* div.align-center * { */\n', b'/*   text-align: left } */\n', b'\n', b'ol.simple, ul.simple {\n', b'  margin-bottom: 1em }\n', b'\n', b'ol.arabic {\n', b'  list-style: decimal }\n', b'\n', b'ol.loweralpha {\n', b'  list-style: lower-alpha }\n', b'\n', b'ol.upperalpha {\n', b'  list-style: upper-alpha }\n', b'\n', b'ol.lowerroman {\n', b'  list-style: lower-roman }\n', b'\n', b'ol.upperroman {\n', b'  list-style: upper-roman }\n', b'\n', b'p.attribution {\n', b'  text-align: right ;\n', b'  margin-left: 50% }\n', b'\n', b'p.caption {\n', b'  font-style: italic }\n', b'\n', b'p.credits {\n', b'  font-style: italic ;\n', b'  font-size: smaller }\n', b'\n', b'p.label {\n', b'  white-space: nowrap }\n', b'\n', b'p.rubric {\n', b'  font-weight: bold ;\n', b'  font-size: larger ;\n', b'  color: maroon ;\n', b'  text-align: center }\n', b'\n', b'p.sidebar-title {\n', b'  font-family: sans-serif ;\n', b'  font-weight: bold ;\n', b'  font-size: larger }\n', b'\n', b'p.sidebar-subtitle {\n', b'  font-family: sans-serif ;\n', b'  font-weight: bold }\n', b'\n', b'p.topic-title {\n', b'  font-weight: bold }\n', b'\n', b'pre.address {\n', b'  margin-bottom: 0 ;\n', b'  margin-top: 0 ;\n', b'  font: inherit }\n', b'\n', b'pre.literal-block, pre.doctest-block, pre.math, pre.code {\n', b'  margin-left: 2em ;\n', b'  margin-right: 2em }\n', b'\n', b'pre.code .ln { color: grey; } /* line numbers */\n', b'pre.code, code { background-color: #eeeeee }\n', b'pre.code .comment, code .comment { color: #5C6576 }\n', b'pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }\n', b'pre.code .literal.string, code .literal.string { color: #0C5404 }\n', b'pre.code .name.builtin, code .name.builtin { color: #352B84 }\n', b'pre.code .deleted, code .deleted { background-color: #DEB0A1}\n', b'pre.code .inserted, code .inserted { background-color: #A3D289}\n', b'\n', b'span.classifier {\n', b'  font-family: sans-serif ;\n', b'  font-style: oblique }\n', b'\n', b'span.classifier-delimiter {\n', b'  font-family: sans-serif ;\n', b'  font-weight: bold }\n', b'\n', b'span.interpreted {\n', b'  font-family: sans-serif }\n', b'\n', b'span.option {\n', b'  white-space: nowrap }\n', b'\n', b'span.pre {\n', b'  white-space: pre }\n', b'\n', b'span.problematic {\n', b'  color: red }\n', b'\n', b'span.section-subtitle {\n', b'  /* font-size relative to parent (h1..h6 element) */\n', b'  font-size: 80% }\n', b'\n', b'table.citation {\n', b'  border-left: solid 1px gray;\n', b'  margin-left: 1px }\n', b'\n', b'table.docinfo {\n', b'  margin: 2em 4em }\n', b'\n', b'table.docutils {\n', b'  margin-top: 0.5em ;\n', b'  margin-bottom: 0.5em }\n', b'\n', b'table.footnote {\n', b'  border-left: solid 1px black;\n', b'  margin-left: 1px }\n', b'\n', b'table.docutils td, table.docutils th,\n', b'table.docinfo td, table.docinfo th {\n', b'  padding-left: 0.5em ;\n', b'  padding-right: 0.5em ;\n', b'  vertical-align: top }\n', b'\n', b'table.docutils th.field-name, table.docinfo th.docinfo-name {\n', b'  font-weight: bold ;\n', b'  text-align: left ;\n', b'  white-space: nowrap ;\n', b'  padding-left: 0 }\n', b'\n', b'/* "booktabs" style (no vertical lines) */\n', b'table.docutils.booktabs {\n', b'  border: 0px;\n', b'  border-top: 2px solid;\n', b'  border-bottom: 2px solid;\n', b'  border-collapse: collapse;\n', b'}\n', b'table.docutils.booktabs * {\n', b'  border: 0px;\n', b'}\n', b'table.docutils.booktabs th {\n', b'  border-bottom: thin solid;\n', b'  text-align: left;\n', b'}\n', b'\n', b'h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,\n', b'h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {\n', b'  font-size: 100% }\n', b'\n', b'ul.auto-toc {\n', b'  list-style-type: none }\n', b'\n', b'</style>\n', b'</head>\n', b'<body>\n', b'<div class="document" id="homepage-of-ae663-ae425-software-development-techniques-in-engineering-and-science">\n', b'<h1 class="title">Homepage of AE663/AE425: Software Development Techniques in Engineering and Science</h1>\n', b'<h2 class="subtitle" id="announcements">Announcements</h2>\n', b'\n', b'<p><strong>2nd Aug</strong>: We will have another bash test sometime soon (night post 8:30pm).\n', b"In future, if the server hangs beyond 10 minutes, please consider the test cancelled. Also visit this page to see announcements. Moodle emails don't come\n", b'immediately.  (It is awkward for us that students keep trying for an hour or so.)\n', b'There is a bash assignment: submit this by Monday 8th Aug morning 8am.\n', b'<a class="reference external" href="http://www.ee.iitb.ac.in/~belur/sdes/bash-exercise16.html">http://www.ee.iitb.ac.in/~belur/sdes/bash-exercise16.html</a></p>\n', b"<p><strong>1st Aug</strong>: There were server issues due to which the bash test didn't\n", b'happen smoothly for many students. Something will be worked out for\n', b'all students again. Apologies.</p>\n', b'<p><strong>27th July</strong>: Please practise the problems on Using-Linux-Tools and\n', b'bash kept at\n', b'<a class="reference external" href="http://www.ee.iitb.ac.in/~belur/sdes/files/exercises-ult-bash-basic.txt">http://www.ee.iitb.ac.in/~belur/sdes/files/exercises-ult-bash-basic.txt</a>\n', b'We will have a test on Thursday (28th July) either in the class or later.\n', b'Read the remaining slides (link below in the announcement of 21st July).\n', b'More about pipe (|) and ampersand (&amp;) and also &quot;AND&quot; (&amp;&amp;) can be found\n', b'at: <a class="reference external" href="http://www.gnu.org/software/bash/manual/bashref.html#Lists">http://www.gnu.org/software/bash/manual/bashref.html#Lists</a>.\n', b'Thanks to Ashwith for pointing out a way to get just the header and\n', b'also the <strong>rest</strong> sorted using pipe and &amp;&amp;. See above exercises.\n', b'More about the pipe in the useful youtube video links he sent me:</p>\n', b'<blockquote>\n', b'<ol class="arabic simple">\n', b'<li>Brian Kernighan on the pipeline: <a class="reference external" href="https://youtu.be/bKzonnwoR2I">https://youtu.be/bKzonnwoR2I</a></li>\n', b'<li>An older and detailed video with a concrete application: <a class="reference external" href="https://youtu.be/tc4ROCJYbm0">https://youtu.be/tc4ROCJYbm0</a></li>\n', b'</ol>\n', b'</blockquote>\n', b'<p><strong>25th July</strong>: All attendees of the course SDES are required to\n', b'enrol themselves into the AE 663 course\n', b'on the iitb-moodle (at <a class="reference external" href="http://moodle.iitb.ac.in">http://moodle.iitb.ac.in</a>). Please use\n', b'code &quot;sdes&quot; (without the quotes, all small) when prompted for a code.\n', b'(Whether you are crediting/auditing AE 425 or not, we will\n', b'use the moodle only of AE 663 to ensure that only one forum will\n', b'be active and all assignments/announcements will be only on\n', b'AE 663 moodle.) An email about this is being sent on 25th July\n', b"5pm. In case you didn't get the email, then (and only then) write\n", b'to me at belur-at-iitb-dot-ac-in. Thank you. -Madhu</p>\n', b"<p><strong>21st July</strong>: Today's class (at 5:30pm, in LCC 101) will start with\n", b'Linux-tools and the Bash shell. Please bring your laptops with\n', b'GNU/Linux installed. With Ubuntu, we can start the terminal using\n', b'Ctrl-Alt-t, but for other variants, the command might be different.\n', b'Please look up how to start Bash in your OS and then come to the class.\n', b'The slides are at:\n', b'<a class="reference external" href="http://www.ee.iitb.ac.in/~belur/sdes/files/3-ult-basic-bash-slides.pdf">http://www.ee.iitb.ac.in/~belur/sdes/files/3-ult-basic-bash-slides.pdf</a></p>\n', b'<p><strong>19th July</strong>: We had a careful look at the submitted codes and the marks.\n', b'We have decided the cut-off and there will be <strong>no</strong> retest.</p>\n', b'<blockquote>\n', b'<ul class="simple">\n', b'<li>109 students appeared for the test as per the interface.</li>\n', b'<li>101 students only were inside the classroom! We will return to the issue\n', b'of these 8 students later.</li>\n', b'<li>50 students out of 109 got 13 marks and above (out of 20).\n', b'Only these are <strong>qualified</strong>.</li>\n', b'<li>At most 5 minutes were lost. Most students lost just a minute or two.\n', b'So no retest. The submitted version of each code that we used for\n', b'for correction. There cannot be re-evaluation.</li>\n', b'<li>If you are not selected in this course, please credit another and we welcome\n', b'you to audit this course.</li>\n', b'<li>By Saturday, we expect that each one of you can either login and see your\n', b'submitted answers/codes, or we send you by email. They are visible\n', b'to us in our user-interface, but not yet in a form that can be mass-sent to you\n', b'individually.</li>\n', b'</ul>\n', b'</blockquote>\n', b'<p>The list of students getting 13 or more marks is at:\n', b'<a class="reference external" href="http://www.ee.iitb.ac.in/~belur/sdes/crediting.html">http://www.ee.iitb.ac.in/~belur/sdes/crediting.html</a></p>\n', b'<p><strong>Venue for all classes</strong>: LC 101 (Lecture hall complex: KReSIT side)</p>\n', b'<dl class="docutils">\n', b'<dt><strong>Please note:</strong></dt>\n', b'<dd><ul class="first last simple">\n', b'<li>Please bring your own laptops for the test. Help towards installation of\n', b'necessary packages <strong>cannot</strong> be provided in the class. Thank you for\n', b'coming on 17th evening and making good use of the mock-test.</li>\n', b'<li>Only those participants who qualify the test will be allowed to credit the\n', b'course. Others can audit or sit-through.</li>\n', b'<li>CS students (either UG or PG) cannot <em>credit</em> the course. Only the\n', b'audit option is available to them.</li>\n', b'</ul>\n', b'</dd>\n', b'</dl>\n', b'<p>Syllabus for the qualifying test (as sent in the email):</p>\n', b'<dl class="docutils">\n', b'<dt>Basic Python:</dt>\n', b'<dd><ul class="first last simple">\n', b'<li>basic types (int, float, complex, bools)</li>\n', b'<li>basic containers (list, dictionaries)</li>\n', b'<li>functions, returning output</li>\n', b'<li>for, while loops, if-elif-else</li>\n', b'</ul>\n', b'</dd>\n', b'</dl>\n', b'<p>(Though the course has topics other than Python and Advanced topics\n', b'within Python, our elimination test is only on Basic Python: in particular\n', b'the above topics.)</p>\n', b'<p>The test will be held on the first day of the class. (As soon as the timetable\n', b'is announced, this page will be updated. Most likely, the test is on 18th July,\n', b'Monday, at 5:30pm). The test is on basic python and candidates are required\n', b'to bring their own laptop for the test and have to have their own laptop\n', b'throughout the course. Please arrange to borrow a laptop from your friend\n', b'for each class if you do not have one.</p>\n', b'<p>An opportunity for you to try out sample problems is provided for you:\n', b'please visit CFD lab, ground floor, Aero-Annexe (below HSS dept): between\n', b'5:30pm and 7:30pm. Please bring <strong>your own</strong> laptops. We will help you\n', b'make a login, etc. only. Computers are being provided neither for\n', b'the sample test (on Sunday evening) nor for the main test (on Monday evening).</p>\n', b'<p>Here is a link for you to see two examples of python questions: one correct\n', b'and two wrong answers per question.\n', b'<a class="reference external" href="http://www.ee.iitb.ac.in/~belur/sdes/July16sample.html">http://www.ee.iitb.ac.in/~belur/sdes/July16sample.html</a></p>\n', b'<p>In order to help us <strong>plan</strong> the qualifying test better,\n', b'please fill the following google form:\n', b'<a class="reference external" href="http://goo.gl/forms/k6dCHC3Sw0IBZv6z1">http://goo.gl/forms/k6dCHC3Sw0IBZv6z1</a></p>\n', b'<p>This form will only help us conduct the test better: no <strong>decision</strong>\n', b'is going to be taken based on this information.</p>\n', b'<p>Some frequently asked questions:</p>\n', b'<blockquote>\n', b'<ul>\n', b'<li><dl class="first docutils">\n', b'<dt>I do not intend to <em>credit</em> the course. Is the test obligatory?</dt>\n', b'<dd><p class="first last">The test is <strong>obligatory</strong> only to those <em>crediting</em> the course. Others\n', b'are <em>encouraged</em> to appear to check their preparedness for the course.</p>\n', b'</dd>\n', b'</dl>\n', b'</li>\n', b'<li><dl class="first docutils">\n', b'<dt>Can I appear for the test later because I have prior commitments?</dt>\n', b'<dd><p class="first last">No. We have just one qualifying test: passing the test is <strong>obligatory</strong>\n', b'in order to credit the course.</p>\n', b'</dd>\n', b'</dl>\n', b'</li>\n', b'<li><dl class="first docutils">\n', b'<dt>I have a different course during this slot. Can we have it at another time?</dt>\n', b'<dd><p class="first last">No. Anyway only one course is possible for registering for each slot.\n', b'So you have to skip your other class today and attend SDES course in\n', b'slot 12 in order to appear for the test.</p>\n', b'</dd>\n', b'</dl>\n', b'</li>\n', b'</ul>\n', b'</blockquote>\n', b'<p>Course syllabus in brief:</p>\n', b'<blockquote>\n', b'<ul class="simple">\n', b'<li>Version control system: git</li>\n', b'<li>Using Linux tools and bash</li>\n', b'<li>Latex, rst, markdown, sphinx</li>\n', b'<li>Basic and Advanced Python</li>\n', b'</ul>\n', b'</blockquote>\n', b'<p>Details about the above topics can be found from our previous course\n', b'website: <a class="reference external" href="http://www.fossee.in/sdes-iitb">http://www.fossee.in/sdes-iitb</a></p>\n', b'<p>Madhu (on behalf of all instructors: Prof. Prabhu Ramachandran,\n', b'Prof. Kumar Appaiah)</p>\n', b'<p><em>Page updated on 2nd August, 2016</em></p>\n', b'</div>\n', b'</body>\n', b'</html>\n']