For loops

a)

   1 for i in range(0,4,1):
   2      print i
   3   
   4 0
   5 1 
   6 2
   7 3

Solution:

   1 for i in range(0,4,1):
   2      for j in range(0,4,1):
   3                 print i,j
   4 
   5 == b) ==
   6 {{{
   7 0 0
   8 0 1
   9 0 2
  10 0 3
  11 1 0
  12 1 1
  13 1 2
  14 1 3
  15 2 0
  16 2 1
  17 2 2
  18 2 3
  19 3 0
  20 3 1
  21 3 2
  22 3 3

Solution:

Data types

A=dict([('a',1),('b',2)])

Please specify the data types:

Provide an alternative way to assign A

Scipy numeric types

from scipy import *

One byte consists of eight bit and covers the value range of 0..255 (uint8, unsigned integer) or -128..127.

   1 b=int8(128)
   2 -128 # Invalid range
   3 
   4 b.nbytes
   5 1

a)

What is the value range of the following types and how many bytes are allocated in the memory?

Solution:

b)

How many bytes are allocated in the memory by these floating point types?

Solution:

Data structures

a)

   1 D={'A':array(range(10)),'B':array(range(10))+1}

Solution:

Reading and practicing

Install python and ipython on your computer and read through the tutorial which comes with the documentation. There are translations in other languages: