From 9588711a2dc515e817c3b79c2d326773833f47c9 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Fri, 10 Oct 2014 21:03:22 +0200 Subject: [PATCH] added first examples of chapter 06: tuples --- python_3_oop/chapter06/tuples.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 python_3_oop/chapter06/tuples.py diff --git a/python_3_oop/chapter06/tuples.py b/python_3_oop/chapter06/tuples.py new file mode 100644 index 0000000..1c745ff --- /dev/null +++ b/python_3_oop/chapter06/tuples.py @@ -0,0 +1,14 @@ +import datetime + + +def middle(stock, date): + + symbol, current, high, low = stock + return ((high + low) / 2), date + + +tuple = ("GOOG", 613.30, 625.86, 610.50) +mid_value, date = middle(tuple, datetime.datetime.now()) +print("middle value: {} at date {}".format(mid_value, date)) +print("high value: {}".format(tuple[2])) +print(tuple[1:3]) \ No newline at end of file