/[dtapublic]/projs/dtats/trunk/projs/2018/20181111_learning_python/lutz_5th_ed/chapter_05/chapter_05.py
ViewVC logotype

Contents of /projs/dtats/trunk/projs/2018/20181111_learning_python/lutz_5th_ed/chapter_05/chapter_05.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 261 - (show annotations) (download) (as text)
Sat Nov 17 20:52:53 2018 UTC (5 years, 11 months ago) by dashley
File MIME type: text/x-python
File size: 1872 byte(s)
Initial creation of Chapter 5 notes.
1 #!/usr/local/bin/python
2 #----------------------------------------------------------------------------------------------------
3 #$Header: svn://localhost/dtapublic/projs/dtats/trunk/projs/2018/20181111_learning_python/lutz_5th_ed/chapter_04/chapter_04.py 253 2018-11-12 02:11:09Z dashley $
4 #----------------------------------------------------------------------------------------------------
5 #David T. Ashley, 11/2018
6 #----------------------------------------------------------------------------------------------------
7 #This file contains notes and experiments as I worked through Mark Lutz's book, "Learning
8 #Python: Powerful Object-Oriented Programming 5th Edition, Kindle Edition", Chapter 5.
9 #----------------------------------------------------------------------------------------------------
10 import sys
11 import math #Many math functions available in Python libraries.
12
13 #Numeric Types
14 #-------------
15
16 #Numeric Literals
17 # o Integers as expected.
18 # o Octal: 0o177
19 # o Hex: 0x9ff
20 # o Binary: 0b101010
21 # o Complex Number: 3+4j, 3j
22
23 #Floating points are implemented as C "double"s.
24
25 #Integer promotion to arbitrary length is automatic in Python 3.X.
26 #Normal and long integers have been merged.
27
28 #Built-in calls hex(), oct(), and bin() convert an integer to that
29 #representation.
30 print(hex(41213))
31 print(oct(41213))
32 print(bin(41213))
33
34 #Complex numbers represented internally with a pair of floating point numbers.
35 c = 1j
36 c2 = c*c
37 print(c)
38 print(c2)
39
40 #Complex numbers may also be crated with the complex() built-in call.
41 c3 = complex(-4.29, 3.22)
42 print(c3)
43
44 #x//y floor division.
45 print(49.0/5.0)
46 print(49.0//5.0)
47
48 #Comparison operators may be chained: x < y < z is the same as
49 #x < y and y < z.
50
51
52
53 #----------------------------------------------------------------------------------------------------
54

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25