# ---
# title: "Loop over maps, numpy arrays"
# date: 2020-04-12T14:41:32+02:00
# author: "<NAME>"
# type: technical_note
# draft: false
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ###  Loop over maps

# +
# Definition of dictionary
europe = {'spain':'madrid', 'france':'paris', 'germany':'berlin',
          'norway':'oslo', 'italy':'rome', 'poland':'warsaw', 'austria':'vienna' }
          
# Iterate over europe
for k,v in europe.items():
    print('the capital of ' + str(k) +' is ' + str(v))
# -

# ### Loop over 1D Numpy array

import numpy as np
np_height = [1.2,32,23.2,23.1]
# For loop over np_height
for x in np_height:
    print(x)

# ### Loop over 2D Numpy array

import numpy as np
baseball = [[180, 78.4],
            [215, 102.7],
            [210, 98.5],
            [188, 75.2]]
np_baseball = np.array(baseball)

# flatten, printing rows sequentially
for x in np.nditer(np_baseball):
    print(x)

StarcoderdataJupyterScriptsDedupFiltered