Skip to content

Commit 0d07cb5

Browse files
17
1 parent 1101479 commit 0d07cb5

File tree

2 files changed

+121
-24
lines changed

2 files changed

+121
-24
lines changed

exercises.ipynb

+11-3
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,18 @@
475475
},
476476
{
477477
"cell_type": "code",
478-
"execution_count": null,
478+
"execution_count": 1,
479479
"id": "0290b0d9",
480480
"metadata": {},
481-
"outputs": [],
481+
"outputs": [
482+
{
483+
"name": "stdout",
484+
"output_type": "stream",
485+
"text": [
486+
"2000,2002,2004,2006,2008,2020,2022,2024,2026,2028,2040,2042,2044,2046,2048,2060,2062,2064,2066,2068,2080,2082,2084,2086,2088,2200,2202,2204,2206,2208,2220,2222,2224,2226,2228,2240,2242,2244,2246,2248,2260,2262,2264,2266,2268,2280,2282,2284,2286,2288,2400,2402,2404,2406,2408,2420,2422,2424,2426,2428,2440,2442,2444,2446,2448,2460,2462,2464,2466,2468,2480,2482,2484,2486,2488,2600,2602,2604,2606,2608,2620,2622,2624,2626,2628,2640,2642,2644,2646,2648,2660,2662,2664,2666,2668,2680,2682,2684,2686,2688,2800,2802,2804,2806,2808,2820,2822,2824,2826,2828,2840,2842,2844,2846,2848,2860,2862,2864,2866,2868,2880,2882,2884,2886,2888\n"
487+
]
488+
}
489+
],
482490
"source": [
483491
"values = []\n",
484492
"for i in range(1000, 3001):\n",
@@ -3470,7 +3478,7 @@
34703478
"name": "python",
34713479
"nbconvert_exporter": "python",
34723480
"pygments_lexer": "ipython3",
3473-
"version": "3.8.10"
3481+
"version": "3.9.13"
34743482
}
34753483
},
34763484
"nbformat": 4,

exercises_no_ans.ipynb

+110-21
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@
568568
},
569569
{
570570
"cell_type": "code",
571-
"execution_count": null,
571+
"execution_count": 2,
572572
"id": "565b7663",
573573
"metadata": {
574574
"attributes": {
@@ -578,9 +578,23 @@
578578
"id": ""
579579
}
580580
},
581-
"outputs": [],
581+
"outputs": [
582+
{
583+
"name": "stdout",
584+
"output_type": "stream",
585+
"text": [
586+
"1010\n"
587+
]
588+
}
589+
],
582590
"source": [
583-
" "
591+
"res = []\n",
592+
"items = input().split(',')\n",
593+
"for cur in items:\n",
594+
" temp = int(cur,2)\n",
595+
" if temp % 5 == 0:\n",
596+
" res.append(cur)\n",
597+
"print(','.join(res))"
584598
]
585599
},
586600
{
@@ -603,7 +617,7 @@
603617
},
604618
{
605619
"cell_type": "code",
606-
"execution_count": null,
620+
"execution_count": 3,
607621
"id": "fd572660",
608622
"metadata": {
609623
"attributes": {
@@ -613,9 +627,22 @@
613627
"id": ""
614628
}
615629
},
616-
"outputs": [],
630+
"outputs": [
631+
{
632+
"name": "stdout",
633+
"output_type": "stream",
634+
"text": [
635+
"2000,2002,2004,2006,2008,2020,2022,2024,2026,2028,2040,2042,2044,2046,2048,2060,2062,2064,2066,2068,2080,2082,2084,2086,2088,2200,2202,2204,2206,2208,2220,2222,2224,2226,2228,2240,2242,2244,2246,2248,2260,2262,2264,2266,2268,2280,2282,2284,2286,2288,2400,2402,2404,2406,2408,2420,2422,2424,2426,2428,2440,2442,2444,2446,2448,2460,2462,2464,2466,2468,2480,2482,2484,2486,2488,2600,2602,2604,2606,2608,2620,2622,2624,2626,2628,2640,2642,2644,2646,2648,2660,2662,2664,2666,2668,2680,2682,2684,2686,2688,2800,2802,2804,2806,2808,2820,2822,2824,2826,2828,2840,2842,2844,2846,2848,2860,2862,2864,2866,2868,2880,2882,2884,2886,2888\n"
636+
]
637+
}
638+
],
617639
"source": [
618-
" "
640+
"res = []\n",
641+
"for iter in range(1000, 3001):\n",
642+
" iter = str(iter)\n",
643+
" if all(int(i)%2 == 0 for i in iter):\n",
644+
" res.append(iter)\n",
645+
"print(','.join(res))"
619646
]
620647
},
621648
{
@@ -642,7 +669,7 @@
642669
},
643670
{
644671
"cell_type": "code",
645-
"execution_count": null,
672+
"execution_count": 4,
646673
"id": "761e1580",
647674
"metadata": {
648675
"attributes": {
@@ -652,9 +679,25 @@
652679
"id": ""
653680
}
654681
},
655-
"outputs": [],
682+
"outputs": [
683+
{
684+
"name": "stdout",
685+
"output_type": "stream",
686+
"text": [
687+
"LETTERS 10 DIGITS 3\n"
688+
]
689+
}
690+
],
656691
"source": [
657-
" "
692+
"items = input()\n",
693+
"digit = 0\n",
694+
"alpha = 0\n",
695+
"for it in items:\n",
696+
" if it.isdigit():\n",
697+
" digit += 1\n",
698+
" elif it.isalpha():\n",
699+
" alpha += 1\n",
700+
"print(\"LETTERS {} DIGITS {}\".format(alpha,digit))"
658701
]
659702
},
660703
{
@@ -681,7 +724,7 @@
681724
},
682725
{
683726
"cell_type": "code",
684-
"execution_count": null,
727+
"execution_count": 5,
685728
"id": "dca14c5c",
686729
"metadata": {
687730
"attributes": {
@@ -691,9 +734,25 @@
691734
"id": ""
692735
}
693736
},
694-
"outputs": [],
737+
"outputs": [
738+
{
739+
"name": "stdout",
740+
"output_type": "stream",
741+
"text": [
742+
"upp 1 low 9\n"
743+
]
744+
}
745+
],
695746
"source": [
696-
" "
747+
"item = input()\n",
748+
"upper = 0\n",
749+
"lower = 0\n",
750+
"for it in item:\n",
751+
" if it.isupper():\n",
752+
" upper += 1\n",
753+
" elif it.islower():\n",
754+
" lower += 1\n",
755+
"print(\"upp {} low {}\".format(upper,lower))"
697756
]
698757
},
699758
{
@@ -719,7 +778,7 @@
719778
},
720779
{
721780
"cell_type": "code",
722-
"execution_count": null,
781+
"execution_count": 7,
723782
"id": "be750e9e",
724783
"metadata": {
725784
"attributes": {
@@ -729,9 +788,21 @@
729788
"id": ""
730789
}
731790
},
732-
"outputs": [],
791+
"outputs": [
792+
{
793+
"name": "stdout",
794+
"output_type": "stream",
795+
"text": [
796+
"11106\n"
797+
]
798+
}
799+
],
733800
"source": [
734-
" "
801+
"item = input()\n",
802+
"res = 0\n",
803+
"for size in range(1,5):\n",
804+
" res += int(item * size)\n",
805+
"print( res )"
735806
]
736807
},
737808
{
@@ -757,7 +828,7 @@
757828
},
758829
{
759830
"cell_type": "code",
760-
"execution_count": null,
831+
"execution_count": 9,
761832
"id": "05fe16f6",
762833
"metadata": {
763834
"attributes": {
@@ -767,9 +838,19 @@
767838
"id": ""
768839
}
769840
},
770-
"outputs": [],
841+
"outputs": [
842+
{
843+
"name": "stdout",
844+
"output_type": "stream",
845+
"text": [
846+
"1,3,5,7,9\n"
847+
]
848+
}
849+
],
771850
"source": [
772-
" "
851+
"items = input().split(',')\n",
852+
"items = [item for item in items if int(item)%2 != 0]\n",
853+
"print(\",\".join(items))"
773854
]
774855
},
775856
{
@@ -802,7 +883,7 @@
802883
},
803884
{
804885
"cell_type": "code",
805-
"execution_count": null,
886+
"execution_count": 10,
806887
"id": "730abfde",
807888
"metadata": {
808889
"attributes": {
@@ -814,7 +895,15 @@
814895
},
815896
"outputs": [],
816897
"source": [
817-
" "
898+
"res = 0\n",
899+
"while True:\n",
900+
" items = input().split(\" \")\n",
901+
" if not items: break\n",
902+
" if items[0] == 'D':\n",
903+
" res += int(items[1])\n",
904+
" elif items[0] == 'W':\n",
905+
" res -= int(items[1])\n",
906+
"print(res)"
818907
]
819908
},
820909
{
@@ -3644,7 +3733,7 @@
36443733
"name": "python",
36453734
"nbconvert_exporter": "python",
36463735
"pygments_lexer": "ipython3",
3647-
"version": "3.8.10"
3736+
"version": "3.9.13"
36483737
}
36493738
},
36503739
"nbformat": 4,

0 commit comments

Comments
 (0)