File: if.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (70 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def f(a, b):
    """
    >>> f(0,0)
    0
    >>> f(1,2)
    2
    >>> f(1,-1)
    1
    """
    x = 0
    if a:
        x = 1
    if a+b:
        x = 2
    return x

def g(a, b):
    """
    >>> g(1,2)
    1
    >>> g(0,2)
    2
    >>> g(0,0)
    0
    """
    x = 0
    if a:
        x = 1
    elif b:
        x = 2
    return x

def h(a, b):
    """
    >>> h(1,2)
    1
    >>> h(0,2)
    2
    >>> h(0,0)
    3
    """
    x = 0
    if a:
        x = 1
    elif b:
        x = 2
    else:
        x = 3
    return x

try:
    import __builtin__  as builtins
except ImportError:
    import builtins

def i(a, b):
    """
    >>> i(1,2)
    1
    >>> i(2,2)
    2
    >>> i(2,1)
    0
    """
    x = 0
    if builtins.str(a).upper() == u"1":
        x = 1
    if builtins.str(a+b).lower() not in (u"1", u"3"):
        x = 2
    return x