Python 3.2.5 (default, May 15 2013, 23:07:10) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ #Checking Collatz conjecture for a given number >>> Please enter a positive integer to apply Collatz algorithm: 7 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 7 is OK ( 16 iters) #Setting the "end" parameter of print() function to " " >>> ================================ RESTART ================================ >>> Please enter a positive integer to apply Collatz algorithm: 19 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 19 is OK ( 20 iters) >>> ================================ RESTART ================================ #Checking Collatz conjecture for a range of numbers (from 1 to ...) >>> ================================ RESTART ================================ >>> Checl Collatz conj. from 1 to...5 1 1 is OK ( 0 iters) 2 1 2 is OK ( 1 iters) 3 10 5 16 8 4 2 1 3 is OK ( 7 iters) 4 2 1 4 is OK ( 2 iters) 5 16 8 4 2 1 5 is OK ( 5 iters) >>> ================================ RESTART ================================ >>> Checl Collatz conj. from 1 to...100 1 1 is OK ( 0 iters) 2 1 2 is OK ( 1 iters) 3 10 5 16 8 4 2 1 3 is OK ( 7 iters) 4 2 1 4 is OK ( 2 iters) 5 16 8 4 2 1 5 is OK ( 5 iters) 6 3 10 5 16 8 4 2 1 6 is OK ( 8 iters) 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 7 is OK ( 16 iters) 8 4 2 1 8 is OK ( 3 iters) 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 9 is OK ( 19 iters) 10 5 16 8 4 2 1 10 is OK ( 6 iters) 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 11 is OK ( 14 iters) 12 6 3 10 5 16 8 4 2 1 12 is OK ( 9 iters) 13 40 20 10 5 16 8 4 2 1 13 is OK ( 9 iters) 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 14 is OK ( 17 iters) 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 15 is OK ( 17 iters) 16 8 4 2 1 16 is OK ( 4 iters) 17 52 26 13 40 20 10 5 16 8 4 2 1 17 is OK ( 12 iters) 18 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 18 is OK ( 20 iters) 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 19 is OK ( 20 iters) 20 10 5 16 8 4 2 1 20 is OK ( 7 iters) 21 64 32 16 8 4 2 1 21 is OK ( 7 iters) 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 22 is OK ( 15 iters) 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 23 is OK ( 15 iters) 24 12 6 3 10 5 16 8 4 2 1 24 is OK ( 10 iters) 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 25 is OK ( 23 iters) 26 13 40 20 10 5 16 8 4 2 1 26 is OK ( 10 iters) 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 27 is OK ( 111 iters) 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 28 is OK ( 18 iters) 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 29 is OK ( 18 iters) 30 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 30 is OK ( 18 iters) 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 31 is OK ( 106 iters) 32 16 8 4 2 1 32 is OK ( 5 iters) 33 100 50 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 33 is OK ( 26 iters) 34 17 52 26 13 40 20 10 5 16 8 4 2 1 34 is OK ( 13 iters) 35 106 53 160 80 40 20 10 5 16 8 4 2 1 35 is OK ( 13 iters) 36 18 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 36 is OK ( 21 iters) 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 37 is OK ( 21 iters) 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 38 is OK ( 21 iters) 39 118 59 178 89 268 134 67 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 39 is OK ( 34 iters) 40 20 10 5 16 8 4 2 1 40 is OK ( 8 iters) 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 41 is OK ( 109 iters) 42 21 64 32 16 8 4 2 1 42 is OK ( 8 iters) 43 130 65 196 98 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 43 is OK ( 29 iters) 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 44 is OK ( 16 iters) 45 136 68 34 17 52 26 13 40 20 10 5 16 8 4 2 1 45 is OK ( 16 iters) 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 46 is OK ( 16 iters) 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 47 is OK ( 104 iters) 48 24 12 6 3 10 5 16 8 4 2 1 48 is OK ( 11 iters) 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 49 is OK ( 24 iters) 50 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 50 is OK ( 24 iters) 51 154 77 232 116 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 51 is OK ( 24 iters) 52 26 13 40 20 10 5 16 8 4 2 1 52 is OK ( 11 iters) 53 160 80 40 20 10 5 16 8 4 2 1 53 is OK ( 11 iters) 54 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 54 is OK ( 112 iters) 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 55 is OK ( 112 iters) 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 56 is OK ( 19 iters) 57 172 86 43 130 65 196 98 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 57 is OK ( 32 iters) 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 58 is OK ( 19 iters) 59 178 89 268 134 67 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 59 is OK ( 32 iters) 60 30 15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 60 is OK ( 19 iters) 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 61 is OK ( 19 iters) 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 62 is OK ( 107 iters) 63 190 95 286 143 430 215 646 323 970 485 1456 728 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 63 is OK ( 107 iters) 64 32 16 8 4 2 1 64 is OK ( 6 iters) 65 196 98 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 65 is OK ( 27 iters) 66 33 100 50 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 66 is OK ( 27 iters) 67 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 67 is OK ( 27 iters) 68 34 17 52 26 13 40 20 10 5 16 8 4 2 1 68 is OK ( 14 iters) 69 208 104 52 26 13 40 20 10 5 16 8 4 2 1 69 is OK ( 14 iters) 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 70 is OK ( 14 iters) 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 71 is OK ( 102 iters) 72 36 18 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 72 is OK ( 22 iters) 73 220 110 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 73 is OK ( 115 iters) 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 74 is OK ( 22 iters) 75 226 113 340 170 85 256 128 64 32 16 8 4 2 1 75 is OK ( 14 iters) 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 76 is OK ( 22 iters) 77 232 116 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 77 is OK ( 22 iters) 78 39 118 59 178 89 268 134 67 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 78 is OK ( 35 iters) 79 238 119 358 179 538 269 808 404 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 79 is OK ( 35 iters) 80 40 20 10 5 16 8 4 2 1 80 is OK ( 9 iters) 81 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 81 is OK ( 22 iters) 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 82 is OK ( 110 iters) 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 83 is OK ( 110 iters) 84 42 21 64 32 16 8 4 2 1 84 is OK ( 9 iters) 85 256 128 64 32 16 8 4 2 1 85 is OK ( 9 iters) 86 43 130 65 196 98 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 86 is OK ( 30 iters) 87 262 131 394 197 592 296 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 87 is OK ( 30 iters) 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 88 is OK ( 17 iters) 89 268 134 67 202 101 304 152 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 89 is OK ( 30 iters) 90 45 136 68 34 17 52 26 13 40 20 10 5 16 8 4 2 1 90 is OK ( 17 iters) 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 91 is OK ( 92 iters) 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 92 is OK ( 17 iters) 93 280 140 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 93 is OK ( 17 iters) 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 94 is OK ( 105 iters) 95 286 143 430 215 646 323 970 485 1456 728 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 95 is OK ( 105 iters) 96 48 24 12 6 3 10 5 16 8 4 2 1 96 is OK ( 12 iters) 97 292 146 73 220 110 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 97 is OK ( 118 iters) 98 49 148 74 37 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 98 is OK ( 25 iters) 99 298 149 448 224 112 56 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 99 is OK ( 25 iters) 100 50 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 100 is OK ( 25 iters) #Testing range() >>> for i in range(10): print(i) 0 1 2 3 4 5 6 7 8 9 >>> for i in range(2,10): print(i) 2 3 4 5 6 7 8 9 >>> for i in range(2,11,2): print(i) 2 4 6 8 10 #We replaced the outer while loop with a for loop >>> ================================ RESTART ================================ >>> Checl Collatz conj. from 1 to...5 1 1 is OK ( 0 iters) 2 1 2 is OK ( 1 iters) 3 10 5 16 8 4 2 1 3 is OK ( 7 iters) 4 2 1 4 is OK ( 2 iters) 5 16 8 4 2 1 5 is OK ( 5 iters) >>> ================================ RESTART ================================ >>> Checl Collatz conj. from 1 to...5 1 1 is OK ( 0 iters) 2 1 2 is OK ( 1 iters) 3 10 5 16 8 4 2 1 3 is OK ( 7 iters) 4 2 1 4 is OK ( 2 iters) 5 16 8 4 2 1 5 is OK ( 5 iters) #lists - an ordered data structure allowing random access (= accessing items in constant time, no matter in which index they are located) #the empty list >>> >>> >>> >>> >>> >>> lst = [] >>> type(lst) # lists in Python can contain items of different types >>> lst = [1, 3.14, True, "michal", print] >>> lst[0] 1 >>> type(lst[4]) >>> type(lst[3]) >>> lst [1, 3.14, True, 'michal', ] >>> lst[4] = 55 >>> lst [1, 3.14, True, 'michal', 55] >>> lst[5] Traceback (most recent call last): File "", line 1, in lst[5] IndexError: list index out of range >>> lst[-1] 55 #list slicing - creates a new list! Does not change the original one >>> lst [1, 3.14, True, 'michal', 55] >>> lst[1:4] [3.14, True, 'michal'] >>> lst[1:5:2] [3.14, 'michal'] #operator + for lists concatenation - creates a new list! >>> lst [1, 3.14, True, 'michal', 55] >>> lst1 = [400, 900] >>> lst3 = lst + lst1 >>> lst3 [1, 3.14, True, 'michal', 55, 400, 900] #Notice that lst , lst1 did not change >>> lst1 [400, 900] >>> lst [1, 3.14, True, 'michal', 55] #Here lst4 changes because of the assignment #However the original items in lst4 are coppied to a new location in memory. #If you would like to append items to an existing list then operator + should not be used. (use instead, append(), extend() or operator +=) >>> lst4 = [1, 2.5, True, "python"] >>> lst4 = lst4 + [10, 20] >>> lst1 [1, 2.5, True, 'python', 10, 20] #the method extend for lists concatenates a given list to the end of an existing list. It changes the original list. >>> lst.extend([99,99,99]) >>> lst [1, 3.14, True, 'michal', 55, 99, 99, 99] #the method append for lists appends an item to the end of an existing list. It changes the original list. >>> lst.append("course") >>> lst [1, 3.14, True, 'michal', 55, 99, 99, 99, 'course'] #creating a nested list >>> lst.append([70,71]) >>> lst [1, 3.14, True, 'michal', 55, 99, 99, 99, 'course', [70, 71]] >>> lst[-1] [70, 71] >>> lst[-1][0] 70 #sum ,len >>> sum([0,-30,-4.5]) -34.5 >>> len(lst) 10 #sorting a list: #sorted() creates a new list with the same items in a sorted order. It does not change the original list. #sort method for lists sorts the list items in-place (changing the original list) >>> lst2 = [0,-30,-4.5] >>> lst2.sort() >>> lst2 [-30, -4.5, 0] >>> lst2 = [0,-30,-4.5] >>> sorted(lst2) [-30, -4.5, 0] >>> lst2 [0, -30, -4.5] #running our count_grades.py code >>> ================================ RESTART ================================ How many grades?4 enter your grade:82 enter your grade:100 enter your grade:45.5 enter your grade:66 2 grades are above the average 73.375 #examples for list comprehension >>> l = [5,4,3,2,1] >>> l [5, 4, 3, 2, 1] >>> new_lst = [x for x in l if x<4] >>> new_lst [3, 2, 1] >>> new_lst = [10*x for x in l if x<4] >>> new_lst [30, 20, 10] >>> new_lst = [True for x in l if x<4] >>> new_lst [True, True, True] >>> new_lst = [True for x in l] >>> new_lst [True, True, True, True, True] #calling the function max2 >>> >>> max2 >>> type(max2) >>> x = 10 >>> y = 15 >>> z = max2(x, y) >>> z 15 >>> z = max2(x, 500) >>> z 500 >>> help(max2) Help on function max2 in module __main__: max2(a, b) max(float,float) ---> float return the maximum od a and b #short circuit evaluation >>> 3/0 Traceback (most recent call last): File "", line 1, in 3/0 ZeroDivisionError: division by zero >>> True or 3/0 True >>>