-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinfo.toml
More file actions
1755 lines (1463 loc) · 67.4 KB
/
Copy pathinfo.toml
File metadata and controls
1755 lines (1463 loc) · 67.4 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
format_version = 1
welcome_message = "Welcome to pythonlings! Save a file to re-run its checks."
final_message = "All exercises complete. 🐍 Nice work."
[[exercises]]
name = "variables1"
path = "exercises/variables/variables1.py"
hint = "Declare a, b, c with concrete values of the right type. A bare 0 is an int; 0.0 is a float; \"\" is the empty string."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables2"
path = "exercises/variables/variables2.py"
hint = "a and b are ints; c is a string. Pick values so a + b == 13 and a % b == 1, then check that str(a) + c equals \"10hello\"."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables3"
path = "exercises/variables/variables3.py"
hint = "Python literal types: 7 is an int, 0.5 is a float, and True is a bool."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables4"
path = "exercises/variables/variables4.py"
hint = "A variable can be reassigned any number of times; each new assignment replaces the old value."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables5"
path = "exercises/variables/variables5.py"
hint = "Augmented assignment: += adds, -= subtracts, *= multiplies. Replace each ??? with the right operator."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables6"
path = "exercises/variables/variables6.py"
hint = "Multiple assignment lets you unpack a tuple in one line: x, y = 1, 2"
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables7"
path = "exercises/variables/variables7.py"
hint = "Python's tuple-swap idiom: a, b = b, a swaps both values in one statement."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables8"
path = "exercises/variables/variables8.py"
hint = "type(x) returns the type object; int(), str(), and float() convert between types."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables9"
path = "exercises/variables/variables9.py"
hint = "Convention: name constants in ALL_CAPS. Then use TAX_RATE in the price expression."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "variables10"
path = "exercises/variables/variables10.py"
hint = "Compute each result as a single expression using width and height: area, perimeter, and the Pythagorean diagonal."
docs = "https://docs.python.org/3/tutorial/introduction.html"
[[exercises]]
name = "strings1"
path = "exercises/strings/strings1.py"
hint = "A string literal is written with quotes: greeting = \"hello\""
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings2"
path = "exercises/strings/strings2.py"
hint = "Concatenate with +: first + \" \" + last gives you the full name."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings3"
path = "exercises/strings/strings3.py"
hint = "word[0] gives the first character; word[-1] gives the last."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings4"
path = "exercises/strings/strings4.py"
hint = "sentence[4:9] extracts characters at indices 4, 5, 6, 7, 8."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings5"
path = "exercises/strings/strings5.py"
hint = "len(text) counts characters; text.upper() and text.lower() change case."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings6"
path = "exercises/strings/strings6.py"
hint = "raw.strip() removes surrounding whitespace; .replace(old, new) swaps substrings."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings7"
path = "exercises/strings/strings7.py"
hint = "csv_line.split(\",\") splits on commas; \", \".join(items) reassembles with a separator."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings8"
path = "exercises/strings/strings8.py"
hint = "An f-string looks like: f\"Hello, {name}! You are {age} years old.\""
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings9"
path = "exercises/strings/strings9.py"
hint = "\"fox\" in sentence returns a bool; sentence.find(\"fox\") returns the start index."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "strings10"
path = "exercises/strings/strings10.py"
hint = "Use f\"...{price:.2f}\" to format the price to two decimal places."
docs = "https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str"
[[exercises]]
name = "conditionals1"
path = "exercises/conditionals/conditionals1.py"
hint = "Replace ??? with the variable name `is_sunny` — when it is True, the if-block runs."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals2"
path = "exercises/conditionals/conditionals2.py"
hint = "Add an `else:` branch after the if-block that returns \"non-positive\"."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals3"
path = "exercises/conditionals/conditionals3.py"
hint = "Add `elif score >= 80: return \"B\"` and `elif score >= 70: return \"C\"` before the final `return \"F\"`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals4"
path = "exercises/conditionals/conditionals4.py"
hint = "Replace the two ???s with the comparison operators `<` and `==`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals5"
path = "exercises/conditionals/conditionals5.py"
hint = "Use `and` to require both conditions in can_ride, and `or` to accept either in gets_discount."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals6"
path = "exercises/conditionals/conditionals6.py"
hint = "is_closed should return `not is_open`; neither_zero should return `a != 0 and b != 0` or use `not` on each."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals7"
path = "exercises/conditionals/conditionals7.py"
hint = "Inside the else block, nest `if is_member: return 8` and `else: return 12`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals8"
path = "exercises/conditionals/conditionals8.py"
hint = "Write `if value:` to test truthiness; add an `else: return \"empty\"` branch."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals9"
path = "exercises/conditionals/conditionals9.py"
hint = "The ternary form is: `return n if n >= 0 else -n`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "conditionals10"
path = "exercises/conditionals/conditionals10.py"
hint = "Use `if n > 100`, `elif n > 0`, `elif n == 0`, `elif n >= -100`, `else` for the five cases."
docs = "https://docs.python.org/3/tutorial/controlflow.html#if-statements"
[[exercises]]
name = "loops1"
path = "exercises/loops/loops1.py"
hint = "Write `for n in range(1, 6): total += n` to add 1 through 5."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops2"
path = "exercises/loops/loops2.py"
hint = "Loop `for fruit in fruits:` and append `fruit.upper()` to `upper_fruits`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops3"
path = "exercises/loops/loops3.py"
hint = "Write `while n > 0:`, append `n`, then `n -= 1` to count down."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops4"
path = "exercises/loops/loops4.py"
hint = "Inside one loop use `total += num` and `product *= num` to accumulate both values."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops5"
path = "exercises/loops/loops5.py"
hint = "Inside `while i < len(values):`, check `if values[i] > 10:`, set `found`, then `break`; always increment `i`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops6"
path = "exercises/loops/loops6.py"
hint = "Inside the loop, `if num % 2 != 0: continue` skips odds; then `evens.append(num)` collects evens."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops7"
path = "exercises/loops/loops7.py"
hint = "Outer loop `for i in range(1, 4)`, inner loop `for j in range(1, 4)`, build each row then append it to table."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops8"
path = "exercises/loops/loops8.py"
hint = "Use `for i, word in enumerate(words, start=1):` and append `f\"{i}: {word}\"` to labeled."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops9"
path = "exercises/loops/loops9.py"
hint = "Use `for name, score in scores.items():` and update top_name/top_score whenever score > top_score."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "loops10"
path = "exercises/loops/loops10.py"
hint = "Use `for i, tx in enumerate(transactions, start=1):`, skip zero-amounts with `continue`, update balance, and append the summary dict."
docs = "https://docs.python.org/3/tutorial/controlflow.html#for-statements"
[[exercises]]
name = "functions1"
path = "exercises/functions/functions1.py"
hint = "The function is called as average(2, 4) — give it two parameters."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions2"
path = "exercises/functions/functions2.py"
hint = "Use `def greet():` with no parameters and `return \"hello\"`, then set `message = greet()`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions3"
path = "exercises/functions/functions3.py"
hint = "Add a parameter name (e.g. `n`) inside the parentheses of `def double()`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions4"
path = "exercises/functions/functions4.py"
hint = "Add the `return` keyword before `n * n` so the function hands a value back to the caller."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions5"
path = "exercises/functions/functions5.py"
hint = "Give `greeting` a default value in the signature: `def make_greeting(name, greeting=\"Hello\"):`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions6"
path = "exercises/functions/functions6.py"
hint = "Use keyword arguments to fix the call order: `describe_pet(name=\"Buddy\", animal_type=\"dog\")`."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions7"
path = "exercises/functions/functions7.py"
hint = "Replace `pass` with `return sum(args)` — `args` is a tuple of all positional arguments."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions8"
path = "exercises/functions/functions8.py"
hint = "Replace `pass` with `return dict(kwargs)` — `kwargs` is already a dict of the keyword arguments."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions9"
path = "exercises/functions/functions9.py"
hint = "Unpack the returned tuple with `lo, hi = min_max(numbers)` instead of assigning the whole tuple to both variables."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "functions10"
path = "exercises/functions/functions10.py"
hint = "Inside `is_palindrome`, compare `s.lower()` with `s.lower()[::-1]` and return the result."
docs = "https://docs.python.org/3/tutorial/controlflow.html#defining-functions"
[[exercises]]
name = "lists1"
path = "exercises/lists/lists1.py"
hint = "A list literal is written with square brackets: colors = [\"red\", \"green\", \"blue\"]"
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists2"
path = "exercises/lists/lists2.py"
hint = "Index 0 is the first element; use numbers[0] for first and numbers[2] = 99 to update."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists3"
path = "exercises/lists/lists3.py"
hint = "items.append(\"cherry\") adds to the end; items.insert(1, \"mango\") inserts at position 1."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists4"
path = "exercises/lists/lists4.py"
hint = "items.remove(\"banana\") deletes by value; last = items.pop() removes and returns the last element."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists5"
path = "exercises/lists/lists5.py"
hint = "Slice syntax: letters[0:3] gives the first three; letters[-2:] gives the last two; letters[2:5] gives indices 2-4."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists6"
path = "exercises/lists/lists6.py"
hint = "scores.sort() sorts in-place; desc = sorted(scores, reverse=True) builds a new descending list."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists7"
path = "exercises/lists/lists7.py"
hint = "len(fruits) counts elements; \"kiwi\" in fruits checks membership; fruits.count(\"apple\") counts occurrences."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists8"
path = "exercises/lists/lists8.py"
hint = "Inside the loop, compute F = temp * 9 / 5 + 32 and append it to fahrenheit."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists9"
path = "exercises/lists/lists9.py"
hint = "matrix[row][col] accesses a cell; row 1 col 1 is matrix[1][1], row 2 col 2 is matrix[2][2]."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "lists10"
path = "exercises/lists/lists10.py"
hint = "Filter with `if record[\"units\"] > 10`, compute revenue as units * price_per_unit, then sum(revenue_list)."
docs = "https://docs.python.org/3/tutorial/datastructures.html#more-on-lists"
[[exercises]]
name = "tuples1"
path = "exercises/tuples/tuples1.py"
hint = "A tuple literal uses parentheses and commas: point = (3, 4)"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples2"
path = "exercises/tuples/tuples2.py"
hint = "Use index 0 for the first element and index -1 (or 2) for the last element of rgb."
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples3"
path = "exercises/tuples/tuples3.py"
hint = "Replace the three ???s with the variable names x, y, z: x, y, z = coordinates"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples4"
path = "exercises/tuples/tuples4.py"
hint = "A single-element tuple needs a trailing comma: solo = (42,)"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples5"
path = "exercises/tuples/tuples5.py"
hint = "Build a new tuple using slicing and concatenation: original[:1] + (99,) + original[2:]"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples6"
path = "exercises/tuples/tuples6.py"
hint = "Use the built-ins min() and max() and return both as a tuple: return (min(numbers), max(numbers))"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples7"
path = "exercises/tuples/tuples7.py"
hint = "The tuple-swap idiom is a single line: a, b = b, a"
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples8"
path = "exercises/tuples/tuples8.py"
hint = "Inside the for loop, add `if score >= 60: passing.append(score)` to collect qualifying scores."
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples9"
path = "exercises/tuples/tuples9.py"
hint = "Tuple keys go directly in the dict literal: {(0, 0): \"origin\", ...}; look up a key with grid[(1, 0)]."
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "tuples10"
path = "exercises/tuples/tuples10.py"
hint = "Unpack each tuple with `for name, score in results`. Use max() with a key for top_student, sum()/len() for average, and a list comprehension for passed."
docs = "https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences"
[[exercises]]
name = "dictionaries1"
path = "exercises/dictionaries/dictionaries1.py"
hint = "A dict literal uses curly braces and colons: ages = {\"alice\": 30, \"bob\": 25}"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries2"
path = "exercises/dictionaries/dictionaries2.py"
hint = "Access a value by its key using square brackets: capitals[\"france\"]"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries3"
path = "exercises/dictionaries/dictionaries3.py"
hint = "Add or update a key with assignment: scores[\"diana\"] = 91 and scores[\"alice\"] = 88"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries4"
path = "exercises/dictionaries/dictionaries4.py"
hint = "Remove with del: `del basket[\"banana\"]`; remove and capture with .pop(): `cherry_count = basket.pop(\"cherry\")`"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries5"
path = "exercises/dictionaries/dictionaries5.py"
hint = "Convert each view to a list: list(inventory.keys()), list(inventory.values()), list(inventory.items())"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries6"
path = "exercises/dictionaries/dictionaries6.py"
hint = "Use .get() with a second argument as the default: config.get(\"timeout\", 30)"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries7"
path = "exercises/dictionaries/dictionaries7.py"
hint = "Iterate with `for item, price in prices.items():` then set `discounted[item] = round(price * 0.9, 2)`"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries8"
path = "exercises/dictionaries/dictionaries8.py"
hint = "The `in` operator checks keys: `\"read\" in permissions` returns True if the key exists."
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries9"
path = "exercises/dictionaries/dictionaries9.py"
hint = "Chain square-bracket access for nested dicts: school[\"students\"][\"alice\"][\"grade\"]"
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "dictionaries10"
path = "exercises/dictionaries/dictionaries10.py"
hint = "Use `freq[word] = freq.get(word, 0) + 1` inside a `for word in words:` loop to count occurrences."
docs = "https://docs.python.org/3/tutorial/datastructures.html#dictionaries"
[[exercises]]
name = "sets1"
path = "exercises/sets/sets1.py"
hint = "A set literal uses curly braces: primes = {2, 3, 5, 7}"
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets2"
path = "exercises/sets/sets2.py"
hint = "colors.add(\"purple\") adds an element; colors.discard(\"orange\") removes it without raising an error."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets3"
path = "exercises/sets/sets3.py"
hint = "The `in` operator returns a bool: has_apple = \"apple\" in fruits"
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets4"
path = "exercises/sets/sets4.py"
hint = "Use `a | b` or `a.union(b)` to get every element that appears in either set."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets5"
path = "exercises/sets/sets5.py"
hint = "Use `a & b` or `a.intersection(b)` to get only the elements present in both sets."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets6"
path = "exercises/sets/sets6.py"
hint = "Use `a - b` or `a.difference(b)` to get elements that are in `a` but not in `b`."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets7"
path = "exercises/sets/sets7.py"
hint = "Pass the list to set(): unique = set(numbers), then use len(unique) for the count."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets8"
path = "exercises/sets/sets8.py"
hint = "Use `small <= big` (or small.issubset(big)) and `big >= small` (or big.issuperset(small))."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets9"
path = "exercises/sets/sets9.py"
hint = "A set comprehension looks like: {n**2 for n in numbers if n % 2 == 0}"
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "sets10"
path = "exercises/sets/sets10.py"
hint = "Convert lists to sets first, then use &, |, and - for intersection, union, and difference."
docs = "https://docs.python.org/3/tutorial/datastructures.html#sets"
[[exercises]]
name = "comprehensions1"
path = "exercises/comprehensions/comprehensions1.py"
hint = "A list comprehension collects expressions: [x for x in range(5)] gives [0, 1, 2, 3, 4]."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions2"
path = "exercises/comprehensions/comprehensions2.py"
hint = "Add an if clause to filter: [x for x in values if x % 2 == 0] keeps only even numbers."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions3"
path = "exercises/comprehensions/comprehensions3.py"
hint = "Transform the expression: [x * 2 for x in values] multiplies every element by 2."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions4"
path = "exercises/comprehensions/comprehensions4.py"
hint = "Use two for clauses: [(r, c) for r in rows for c in cols] iterates every row-column pair."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions5"
path = "exercises/comprehensions/comprehensions5.py"
hint = "A dict comprehension uses {key: val for item in iterable}: {x: x**2 for x in numbers}."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions6"
path = "exercises/comprehensions/comprehensions6.py"
hint = "A set comprehension uses {expr for item in iterable}: {len(w) for w in words}."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions7"
path = "exercises/comprehensions/comprehensions7.py"
hint = "Iterate over a string directly: [c for c in sentence if c in 'aeiou'] extracts vowels."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions8"
path = "exercises/comprehensions/comprehensions8.py"
hint = "Put the ternary inside: ['even' if x % 2 == 0 else 'odd' for x in values]."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions9"
path = "exercises/comprehensions/comprehensions9.py"
hint = "Flatten with two for clauses: [item for sublist in matrix for item in sublist]."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "comprehensions10"
path = "exercises/comprehensions/comprehensions10.py"
hint = "Use enumerate to get index-value pairs: {word: idx for idx, word in enumerate(words)}."
docs = "https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions"
[[exercises]]
name = "exceptions1"
path = "exercises/exceptions/exceptions1.py"
hint = "Wrap the division in try/except ZeroDivisionError and return 'error' in the except branch."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions2"
path = "exercises/exceptions/exceptions2.py"
hint = "Catch the specific exception: except ValueError: return -1."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions3"
path = "exercises/exceptions/exceptions3.py"
hint = "Use 'except ValueError as e:' and return str(e) to surface the built-in error message."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions4"
path = "exercises/exceptions/exceptions4.py"
hint = "Add an else clause after the except block: else: return value * 2."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions5"
path = "exercises/exceptions/exceptions5.py"
hint = "Add a finally clause after the except block: finally: log.append('done')."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions6"
path = "exercises/exceptions/exceptions6.py"
hint = "Use 'raise ValueError' (no message needed) when n is not positive."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions7"
path = "exercises/exceptions/exceptions7.py"
hint = "Use 'raise ValueError(\"age must be between 0 and 120\")' when age is out of range."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions8"
path = "exercises/exceptions/exceptions8.py"
hint = "Add 'except ValueError:', 'except TypeError:', and 'except Exception:' clauses returning the right string."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions9"
path = "exercises/exceptions/exceptions9.py"
hint = "Define 'class InsufficientFundsError(Exception): pass', then raise it with a descriptive message."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "exceptions10"
path = "exercises/exceptions/exceptions10.py"
hint = "Check type first (TypeError), then length (ValueError), then .isalnum() (ValueError); return name.lower() on success."
docs = "https://docs.python.org/3/tutorial/errors.html"
[[exercises]]
name = "file_io1"
path = "exercises/file_io/file_io1.py"
hint = "Replace ??? with the string \"hello, file!\". open(path, \"w\") opens for writing; .write(text) writes the text."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io2"
path = "exercises/file_io/file_io2.py"
hint = "Replace ??? with open(note_path).read() to read the whole file as a string."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io3"
path = "exercises/file_io/file_io3.py"
hint = "Replace ??? with the string \"first entry\". The with-block handles opening and closing automatically."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io4"
path = "exercises/file_io/file_io4.py"
hint = "Change .read() to .readlines() — it returns a list of strings, one per line (newlines included)."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io5"
path = "exercises/file_io/file_io5.py"
hint = "Change the mode from \"w\" (overwrite) to \"a\" (append) so the first line is preserved."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io6"
path = "exercises/file_io/file_io6.py"
hint = "Replace `total += line` with `total += int(line.strip())` to convert each text line to an integer."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io7"
path = "exercises/file_io/file_io7.py"
hint = "Pass a list with newlines appended: fh.writelines(w + \"\\n\" for w in words), or use a for-loop with fh.write(w + \"\\n\")."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io8"
path = "exercises/file_io/file_io8.py"
hint = "Chain .strip() onto the read call: result = fh.read().strip()"
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io9"
path = "exercises/file_io/file_io9.py"
hint = "Split before counting: word_count = len(fh.read().split())"
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "file_io10"
path = "exercises/file_io/file_io10.py"
hint = "Change dst.write(line) to dst.write(line.upper()) to uppercase every line as it is copied."
docs = "https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files"
[[exercises]]
name = "classes1"
path = "exercises/classes/classes1.py"
hint = "Replace ??? with `pass` — a class body must have at least one statement."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes2"
path = "exercises/classes/classes2.py"
hint = "Inside __init__, add `self.name = name` to store the argument on the instance."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes3"
path = "exercises/classes/classes3.py"
hint = "Add `self.y = y` after `self.x = x` inside __init__."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes4"
path = "exercises/classes/classes4.py"
hint = "Change `return 0` to `return self.width * self.height` in the area method."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes5"
path = "exercises/classes/classes5.py"
hint = "Replace `pass` in increment with `self.count += 1`."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes6"
path = "exercises/classes/classes6.py"
hint = "Change `def __init__(self, brand, speed):` to `def __init__(self, brand, speed=0):`."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes7"
path = "exercises/classes/classes7.py"
hint = "Replace ??? with `self.get_name()` — call the other method on self."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes8"
path = "exercises/classes/classes8.py"
hint = "Add `def __str__(self): return f\"Book: {self.title} by {self.author}\"` to the class."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes9"
path = "exercises/classes/classes9.py"
hint = "Add `def __repr__(self): return f\"Color(r={self.r}, g={self.g}, b={self.b})\"` to the class."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes10"
path = "exercises/classes/classes10.py"
hint = "Move `pi = 3.14159` to be a class-level attribute (one indent level inside the class, not inside __init__), and remove the local `pi = 3.14159` line from __init__."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes11"
path = "exercises/classes/classes11.py"
hint = "Add a @classmethod `from_string(cls, s)` that does `return cls(float(s[:-1]))`."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "classes12"
path = "exercises/classes/classes12.py"
hint = "Add __init__(self, owner, balance) to store both attributes; fix deposit to add amount; fix withdraw to subtract (raise ValueError if overdraft); fix __str__ to return the formatted string."
docs = "https://docs.python.org/3/tutorial/classes.html"
[[exercises]]
name = "functional1"
path = "exercises/functional/functional1.py"
hint = "Replace ??? with `lambda x: x * x` (or `lambda x: x ** 2`)."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional2"
path = "exercises/functional/functional2.py"
hint = "Replace ??? with `lambda x: x if x >= 0 else -x`."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional3"
path = "exercises/functional/functional3.py"
hint = "Replace ??? with `lambda x: x * 2` — pass that lambda as the first argument to map()."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional4"
path = "exercises/functional/functional4.py"
hint = "Replace ??? with `lambda x: x % 2 == 0` — pass that lambda as the first argument to filter()."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional5"
path = "exercises/functional/functional5.py"
hint = "Replace ??? with `lambda w: len(w)` to sort words by their length."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional6"
path = "exercises/functional/functional6.py"
hint = "Replace `pass` with `return func(func(value))` — call func on value, then call func on the result."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional7"
path = "exercises/functional/functional7.py"
hint = "Replace `pass` with `return lambda x: x * n` — return a new function that captures n."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional8"
path = "exercises/functional/functional8.py"
hint = "Replace ??? with `lambda a, b: a * b` — reduce multiplies pairs cumulatively to give the product."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional9"
path = "exercises/functional/functional9.py"
hint = "Replace the first ??? with `x < 0 for x in numbers` and the second with `x > 0 for x in positives`."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "functional10"
path = "exercises/functional/functional10.py"
hint = "Three lambdas: `lambda x: x * 2` for map, `lambda x: x > 10` for filter, `lambda a, b: a + b` for reduce."
docs = "https://docs.python.org/3/howto/functional.html"
[[exercises]]
name = "decorators1"
path = "exercises/decorators/decorators1.py"
hint = "Replace `pass` with `return func()` — call the function that was passed in and return its result."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators2"
path = "exercises/decorators/decorators2.py"
hint = "Change `return result` to `return result.upper()` inside the wrapper."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators3"
path = "exercises/decorators/decorators3.py"
hint = "Add `@stamp` on the line directly above `def get_message():` — this applies the decorator automatically."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators4"
path = "exercises/decorators/decorators4.py"
hint = "Capture the return value: `result = func()` then `return result * 2`."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators5"
path = "exercises/decorators/decorators5.py"
hint = "Change `def wrapper():` to `def wrapper(*args, **kwargs):` and `return func()` to `return func(*args, **kwargs)`."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators6"
path = "exercises/decorators/decorators6.py"
hint = "Add `import functools` at the top, then add `@functools.wraps(func)` on the line above `def wrapper`."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators7"
path = "exercises/decorators/decorators7.py"
hint = "Add `wrapper.call_count += 1` as the first line inside the wrapper body, before calling func."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators8"
path = "exercises/decorators/decorators8.py"
hint = "Inside `repeat(n)`, define a `decorator(func)` that returns a `wrapper(*args, **kwargs)` calling func n times in a loop and returning the last result."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators9"
path = "exercises/decorators/decorators9.py"
hint = "Add `@add_b` then `@add_a` above `def get_value():`; the decorator nearest the def is applied first, so `add_a` runs first, then `add_b` wraps that."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "decorators10"
path = "exercises/decorators/decorators10.py"
hint = "Check `if args in wrapper.cache: return wrapper.cache[args]`, otherwise compute, store in `wrapper.cache[args]`, and return the result."
docs = "https://docs.python.org/3/glossary.html#term-decorator"
[[exercises]]
name = "generators1"
path = "exercises/generators/generators1.py"
hint = "Inside the for loop replace `pass` with `yield i` to turn the function into a generator."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators2"
path = "exercises/generators/generators2.py"
hint = "Replace `None` with `list(squares(5))` — calling list() on a generator drains it into a list."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators3"
path = "exercises/generators/generators3.py"
hint = "Add `if i % 2 == 0:` before the pass, then change `pass` to `yield i` so only even numbers are yielded."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators4"
path = "exercises/generators/generators4.py"
hint = "Replace `None` with `(i ** 3 for i in range(1, 6))` — parentheses make a generator expression, not a list."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators5"
path = "exercises/generators/generators5.py"
hint = "Replace each `None` with `next(gen)` — every call advances the generator by one step."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators6"
path = "exercises/generators/generators6.py"
hint = "Add `while True:` with `yield a` and `a += 1` (starting at 1) inside `natural_numbers`; remove the bare `return`."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators7"
path = "exercises/generators/generators7.py"
hint = "Wrap the yield in `while True:` and add `a, b = b, a + b` after the yield to advance the sequence."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators8"
path = "exercises/generators/generators8.py"
hint = "Add `def __iter__(self):` that uses `yield` in a `for i in range(self.start, 0, -1):` loop."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators9"
path = "exercises/generators/generators9.py"
hint = "At the top of `__next__`, add `if self.current >= self.stop: raise StopIteration` before incrementing."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "generators10"
path = "exercises/generators/generators10.py"
hint = "Add `total += n` before the yield, then change `yield n` to `yield total` to emit the running sum."
docs = "https://docs.python.org/3/tutorial/classes.html#generators"
[[exercises]]
name = "context_managers1"
path = "exercises/context_managers/context_managers1.py"
hint = "Replace the open/write lines with `with open(data_path, 'w') as f:` and indent `f.write('hello, context!')` inside."
docs = "https://docs.python.org/3/reference/compound_stmts.html#the-with-statement"
[[exercises]]
name = "context_managers2"
path = "exercises/context_managers/context_managers2.py"
hint = "Use `with open(data_path, 'w') as f:` so Python closes the file automatically; then `f.closed` will be True."
docs = "https://docs.python.org/3/reference/compound_stmts.html#the-with-statement"
[[exercises]]
name = "context_managers3"
path = "exercises/context_managers/context_managers3.py"
hint = "Add `def __enter__(self): return self` and `def __exit__(self, exc_type, exc_val, exc_tb): self.finished = True`."
docs = "https://docs.python.org/3/reference/compound_stmts.html#the-with-statement"
[[exercises]]
name = "context_managers4"
path = "exercises/context_managers/context_managers4.py"
hint = "Inside `__exit__`, replace `pass` with `self.log.append('done')` to record cleanup."
docs = "https://docs.python.org/3/reference/compound_stmts.html#the-with-statement"