List of Python versions

36

Python is the fastest-growing major programming language today. It is the most wanted language for the third year in a row, meaning that developers who do not yet use it say they want to learn it.[1]

The reason for Python's popularity is its many versions.[citation needed] There are in fact 116 versions of Python, including two development versions.

Your task is to output/print a list of all the Python versions, in whatever order you like, and on whatever format you like. You may not use any built-in functions that have this information stored.

You are free to choose the output format, but each version must be identified on the standard way: 1.1, 2.3.0, 2.7.10 and so on.

The complete list2 of Python versions, comma-separated is shown below:

1.1, 1.2, 1.3, 1.4, 1.5, 1.5.1, 1.5.2, 1.6, 2.0, 2.0.1, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.2, 2.2.1, 2.2.2, 2.2.3, 2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.6, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.6.6, 2.6.7, 2.6.8, 2.6.9, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, 2.7.9, 2.7.10, 2.7.11, 2.7.12, 2.7.13, 2.7.14, 2.7.15, 2.7.16, 3.0, 3.0.1, 3.1, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.2 , 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10, 3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.7.0, 3.7.1, 3.7.2, 3.7.3

or by major versions:

1.1
1.2
1.3
1.4
1.5, 1.5.1, 1.5.2
1.6
2.0, 2.0.1
2.1, 2.1.1, 2.1.2, 2.1.3
2.2, 2.2.1, 2.2.2, 2.2.3
2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5
2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4
2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4
2.6, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.6.6, 2.6.7, 2.6.8, 2.6.9
2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, 2.7.9, 2.7.10, 2.7.11, 2.7.12, 2.7.13, 2.7.14, 2.7.15, 2.7.16
3.0, 3.0.1
3.1, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5
3.2, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6
3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5, 3.3.6, 3.3.7
3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10 
3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7
3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8
3.7.0, 3.7.1, 3.7.2, 3.7.3

The challenge is a fixed output challenge, and very close to a , except that the output format is optional.

2The list is taken from the official Python website, here and here. There are some versions that aren't included, such as 0.9.0 .. 0.9.9 and 1.5.1p1. You must use the list above, even if you find versions that aren't included. I've decided to stick with the official lists, since otherwise someone would probably find a 2.1.0.1.2 version or something like that.

Stewie Griffin

Posted 2019-04-16T08:05:29.290

Reputation: 43 471

2I guess we aren't allowed to output 1.1.0 (to make all versions 3 numbers) instead of 1.1? – Kevin Cruijssen – 2019-04-16T09:27:53.517

2You guess correctly @Kevin. I considered allowing it, but went with the official names instead. – Stewie Griffin – 2019-04-16T09:37:39.873

Answers

17

JavaScript (ES6),  128 125  124 bytes

Saved 1 bytes thanks to @OlivierGrégoire

Outputs each version on a separate line. Ordered from highest to lowest major version, and from lowest to highest revision.

f=(r=v=28)=>v?r<parseInt('0111131000244655ah002678b8940'[v],36)?(1+v/10).toFixed(1)+(r|v>22?'.'+r:'')+`
`+f(r+1):f(+!v--):''

Try it online!

How?

The major and minor versions are held in the variable \$v \in [0..27]\$:

  • major = \$\lfloor v/10+1\rfloor\$
  • minor = \$v \bmod 10\$

The revision is held in the variable \$r\ge0\$. The maximum value of \$r\$ depends on \$v\$ and is stored in a lookup table encoded in Base-36. Any \$0\$ in this table means that this version was not released at all.

Besides, we use the test \$v>22\$ to know whether the revision should be included even when it's \$0\$ (starting with Python 3.3.0).

Arnauld

Posted 2019-04-16T08:05:29.290

Reputation: 111 334

5

C# (Visual C# Interactive Compiler), 109 bytes

for(int j,k=1;;k++)for(j=@" [SOH][SOH][SOH][SOH][ETX][SOH][NUL][NUL][NUL][STX][EOT][EOT][ACK][ENQ][ENQ]
[DC1][NUL][NUL][STX][ACK][BEL][BS][VT][BS][TAB][EOT]"[k];j-->0;)Print($"{k*.1+1:N1}"+(j<1&k<17?"":"."+j));

Contains many unprintables, whose codes are shown in the brackets. This is a full program. The null bytes are replaced by \0s in the TIO link, since my device can't copy and paste them.

Saved one byte thanks to @OlivierGregoire.

Try it online! (Thanks to @OlivierGregoire for implanting the null bytes)

Explanation

Each character in the string represents how many minor versions in the major position. For example, the character at index 5(ETX) has an ASCII value of three, and corresponds to the major version 1.5.x which has three minor versions. The program takes the ascii value of the current character and loops that many times, printing the minor versions before moving on to the next major version.

For some versions, there are gaps to the next versions. To fix that, the string contains null bytes, so that the program loops zero times when it encounters those.

The unprintable string contains these character values:

1,1,1,1,3,1,0,0,0,2,4,4,6,5,5,10,17,0,0,2,6,7,8,11,8,9,4

Embodiment of Ignorance

Posted 2019-04-16T08:05:29.290

Reputation: 7 014

Can be shortened with j="..."[k];j-->0;, especially since the order has no importance. Also, can you explain the difference in size between the TIO (115 bytes) and the entry (110 bytes)? – Olivier Grégoire – 2019-04-17T08:34:37.437

@OlivierGrégoire Probably the five null bytes which tio represent as \0 – Sefa – 2019-04-17T09:45:54.800

@Sefa yes, probably... But I'm asking for certainty. – Olivier Grégoire – 2019-04-17T10:37:36.357

@OlivierGrégoire Exactly what Sefa said, I can't really copy-paste the null bytes. If the \0s were replaced by null bytes, it would be 110 bytes – Embodiment of Ignorance – 2019-04-17T14:42:43.567

1

Then, here you are, with a nul-byte TIO

– Olivier Grégoire – 2019-04-17T14:56:34.493

4

Pyth, 52 bytes

.emj\.+W|d>k18,h/k8%k8dbxLG"abbbbdbaceegffkrcghilije

Try it online here.

Output is a nested list, with elements grouped by major and minor version. There is an empty list at the start of the output, and another one after 1.6. Full output is as follows:

[[], ['1.1'], ['1.2'], ['1.3'], ['1.4'], ['1.5', '1.5.1', '1.5.2'], ['1.6'], [], ['2.0', '2.0.1'], ['2.1', '2.1.1', '2.1.2', '2.1.3'], ['2.2', '2.2.1', '2.2.2', '2.2.3'], ['2.3', '2.3.1', '2.3.2', '2.3.3', '2.3.4', '2.3.5'], ['2.4', '2.4.1', '2.4.2', '2.4.3', '2.4.4'], ['2.5', '2.5.1', '2.5.2', '2.5.3', '2.5.4'], ['2.6', '2.6.1', '2.6.2', '2.6.3', '2.6.4', '2.6.5', '2.6.6', '2.6.7', '2.6.8', '2.6.9'], ['2.7', '2.7.1', '2.7.2', '2.7.3', '2.7.4', '2.7.5', '2.7.6', '2.7.7', '2.7.8', '2.7.9', '2.7.10', '2.7.11', '2.7.12', '2.7.13', '2.7.14', '2.7.15', '2.7.16'], ['3.0', '3.0.1'], ['3.1', '3.1.1', '3.1.2', '3.1.3', '3.1.4', '3.1.5'], ['3.2', '3.2.1', '3.2.2', '3.2.3', '3.2.4', '3.2.5', '3.2.6'], ['3.3.0', '3.3.1', '3.3.2', '3.3.3', '3.3.4', '3.3.5', '3.3.6', '3.3.7'], ['3.4.0', '3.4.1', '3.4.2', '3.4.3', '3.4.4', '3.4.5', '3.4.6', '3.4.7', '3.4.8', '3.4.9', '3.4.10'], ['3.5.0', '3.5.1', '3.5.2', '3.5.3', '3.5.4', '3.5.5', '3.5.6', '3.5.7'], ['3.6.0', '3.6.1', '3.6.2', '3.6.3', '3.6.4', '3.6.5', '3.6.6', '3.6.7', '3.6.8'], ['3.7.0', '3.7.1', '3.7.2', '3.7.3']]

If this isn't acceptable, prepend .n to the code to have output as a flattened list, at a cost of 2 bytes.

Sok

Posted 2019-04-16T08:05:29.290

Reputation: 5 592

4

Java (JDK), 134 bytes

v->{for(int a=0,b;;)for(b="0111131000244655:A002678;894".charAt(++a)-48;b-->0;)System.out.printf("%.1f%s ",a*.1+1,b<1&a<23?"":"."+b);}

Try it online!

The versions are printed from the highest to the lowest.

Credits

Olivier Grégoire

Posted 2019-04-16T08:05:29.290

Reputation: 10 647

1(a>1|b>0)&c<a.valueOf(y,36) can be a>1|b>0&&c<a.valueOf(y,36) and c<1&(a<3|b<3)? can be c<1&&a<3|b<3? to save 2 bytes. Relevant Java tip - section Combining bit-wise and logical checks instead of using parenthesis – Kevin Cruijssen – 2019-04-17T07:04:14.757

@KevinCruijssen Thank you, but I made so many changes that your suggestions are now irrelevant... Don't know how to credit you since I don't even use your suggestion anymore :( – Olivier Grégoire – 2019-04-17T07:45:11.350

1Np, instead I will suggest a new golf ;) /10d can be *.1 – Kevin Cruijssen – 2019-04-17T10:38:42.850

1int a=28->int a=1, and remove the condition in the for loop, then add an a++ to save 3 bytes. TIO – Embodiment of Ignorance – 2019-04-17T14:52:29.013

@EmbodimentofIgnorance Since REPL seem accepted in this challenge, that's indeed acceptable. Thank you!

– Olivier Grégoire – 2019-04-17T14:59:46.350

3

Retina, 105 bytes


11* 111131   244655TS  2678E894
L$`.
$&_$.`
T
10
E
11
S
17
.+_
*
Lv$`_+(.)(.)
$1.$2.$.%`
,16`(...)\.0
$1

Try it online! Loosely based on @Arnauld's solution. Explanation:


11* 111131   244655TS  2678E894

Insert the string consisting of 11 spaces followed by the given characters.

L$`.
$&_$.`

For each character, list it suffixed with a _ and its column number.

T
10
E
11
S
17

Convert the three letters to numeric values.

.+_
*

Convert the numeric values to unary.

Lv$`_+(.)(.)
$1.$2.$.%`

For each value up to the given value, use that as the suffix for the version number, extracting the major and minor from the column number.

,16`(...)\.0
$1

Delete the zero suffix for the first 16 versions that have one.

Neil

Posted 2019-04-16T08:05:29.290

Reputation: 95 035

2

Jelly, 51 bytes

+⁵D;ⱮḶ}j€”.
“øṄƇịɱ⁽Ɱj>⁶7,Ẉ¢’b18Ė0ị$Ƈç/€ḣ3$€1¦€17R¤¦

Try it online!

A niladic link that outputs a list of lists of .-separated integers, grouped by major version. On TIO, there’s some footer code to print these prettily.

Nick Kennedy

Posted 2019-04-16T08:05:29.290

Reputation: 11 829

0

33, 484 bytes

"1."es[lz1azpois4m]"1.5"pi"1.5."z1apoiapoi"1.6"pi"2.0"pip".1"pizcz"2.1"''pie"."e''es[lz1azpois3m]"2.2"''pie"."et''es[lz1azpois3m]"2.3"''pie"."et''es[lz1azpois5m]"2.4"''pie"."et''es[lz1azpois4m]"2.5"''pie"."et''es[lz1azpois4m]"2.6"''pie"."et''es[lz1azpois9m]"2.7"''pie"."et''es[lz1azpois16m]"3.0"pip".1"pi"3.1"''pie"."et''es[lz1azpois5m]"3.2"''pie"."et''es[lz1azpois6m]"3.3."''es[lzpoi1azs8m]"3.4."''es[lzpoi1azs11m]"3.5."''es[lzpoi1azs8m]"3.6."''es[lzpoi1azs9m]"3.7."''es[lzpoi1azs4m]

I wanted to give this a go in my brainf*ck-style language.

It prints each python version required for the challenge, delimited by newlines.

Here's a small explanation.

[lz1azpois4m] | Imitates a for loop starting at 1
[  1az    4m] | For i in range 1 through 4
      p       | - Print the string declared previously (1.5., 3.4., etc.)
       o      | - Print the current value of i
        i     | - Print a newline

[lzpoi1azs8m] | Imitates a for loop starting at 0
[     1az 8m] | For i in range 0 through 7
   poi        | Print the version

TheOnlyMrCat

Posted 2019-04-16T08:05:29.290

Reputation: 1 079