Skip to content

Commit ba5b41a

Browse files
committed
pyhton
1 parent fa8b254 commit ba5b41a

File tree

4 files changed

+243
-50
lines changed

4 files changed

+243
-50
lines changed
+111-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,115 @@
11
{
2-
"cells": [],
3-
"metadata": {},
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 7,
6+
"id": "6aef2608",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"ename": "TypeError",
11+
"evalue": "'type' object is not iterable",
12+
"output_type": "error",
13+
"traceback": [
14+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
15+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
16+
"Input \u001b[1;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m sets\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mquestion\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moption\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcurrect_ans\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpoint\u001b[39m\u001b[38;5;124m'\u001b[39m}\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mset\u001b[39m:\n\u001b[0;32m 3\u001b[0m sets\u001b[38;5;241m.\u001b[39msetdefault(\u001b[38;5;28minput\u001b[39m())\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(sets)\n",
17+
"\u001b[1;31mTypeError\u001b[0m: 'type' object is not iterable"
18+
]
19+
}
20+
],
21+
"source": [
22+
"sets={'question','option','currect_ans','point'}\n",
23+
"for i in set:\n",
24+
" sets.setdefault(input())\n",
25+
" print(sets)\n",
26+
" "
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 8,
32+
"id": "100de798",
33+
"metadata": {},
34+
"outputs": [
35+
{
36+
"name": "stdout",
37+
"output_type": "stream",
38+
"text": [
39+
"Enter Your Question: what is python\n",
40+
"Enter Your Option: programming language, software, hardware, none\n",
41+
"programming language\n",
42+
"right answer \n"
43+
]
44+
}
45+
],
46+
"source": [
47+
"question=input('Enter Your Question: ')\n",
48+
"option=input('Enter Your Option: ')\n",
49+
"currect_ans=input()\n",
50+
"point=0\n",
51+
"if currect_ans in option:\n",
52+
" print('right answer ')\n",
53+
" point+=1\n",
54+
"else:\n",
55+
" print('wrong answer')"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"id": "7349bbf6",
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"question_bank=dict{question,option,currect_ans,point}\n",
66+
"for i in question_bank:\n",
67+
" i=input(f'Enter your {i}: ')\n",
68+
" question_bank.append(i)\n",
69+
" print(question_bank)"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"id": "c59e2405",
76+
"metadata": {},
77+
"outputs": [],
78+
"source": []
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": null,
83+
"id": "ba281319",
84+
"metadata": {},
85+
"outputs": [],
86+
"source": []
87+
}
88+
],
89+
"metadata": {
90+
"kernelspec": {
91+
"display_name": "Python 3 (ipykernel)",
92+
"language": "python",
93+
"name": "python3"
94+
},
95+
"language_info": {
96+
"codemirror_mode": {
97+
"name": "ipython",
98+
"version": 3
99+
},
100+
"file_extension": ".py",
101+
"mimetype": "text/x-python",
102+
"name": "python",
103+
"nbconvert_exporter": "python",
104+
"pygments_lexer": "ipython3",
105+
"version": "3.9.12"
106+
},
107+
"vscode": {
108+
"interpreter": {
109+
"hash": "5ae58900cfbb8c43ab3495913814b7cf26024f51651a94ce8bf64d6111688e8d"
110+
}
111+
}
112+
},
4113
"nbformat": 4,
5114
"nbformat_minor": 5
6115
}

collection_practice.ipynb

+21-1
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,29 @@
465465
"cell_type": "code",
466466
"execution_count": null,
467467
"id": "6ff0d875",
468+
"metadata": {
469+
"scrolled": false
470+
},
471+
"outputs": [],
472+
"source": [
473+
"s=['question','option']\n",
474+
"k=dict()\n",
475+
"for i in s:\n",
476+
" r=input('enter')\n",
477+
" k.setdefault(i,k)\n",
478+
"print(s)"
479+
]
480+
},
481+
{
482+
"cell_type": "code",
483+
"execution_count": null,
484+
"id": "1c4a4728",
468485
"metadata": {},
469486
"outputs": [],
470-
"source": []
487+
"source": [
488+
"\n",
489+
"\n"
490+
]
471491
}
472492
],
473493
"metadata": {

function_practice.ipynb

+63-42
Original file line numberDiff line numberDiff line change
@@ -873,29 +873,17 @@
873873
},
874874
{
875875
"cell_type": "code",
876-
"execution_count": 100,
876+
"execution_count": null,
877877
"id": "f3ab9161",
878878
"metadata": {},
879-
"outputs": [
880-
{
881-
"ename": "StopIteration",
882-
"evalue": "",
883-
"output_type": "error",
884-
"traceback": [
885-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
886-
"\u001b[1;31mStopIteration\u001b[0m Traceback (most recent call last)",
887-
"Input \u001b[1;32mIn [100]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mis_odd\u001b[49m\u001b[43m)\u001b[49m\n",
888-
"\u001b[1;31mStopIteration\u001b[0m: "
889-
]
890-
}
891-
],
879+
"outputs": [],
892880
"source": [
893881
"next(is_odd)"
894882
]
895883
},
896884
{
897885
"cell_type": "code",
898-
"execution_count": 103,
886+
"execution_count": null,
899887
"id": "1633c926",
900888
"metadata": {},
901889
"outputs": [],
@@ -905,28 +893,17 @@
905893
},
906894
{
907895
"cell_type": "code",
908-
"execution_count": 104,
896+
"execution_count": null,
909897
"id": "3f2c7f51",
910898
"metadata": {},
911-
"outputs": [
912-
{
913-
"data": {
914-
"text/plain": [
915-
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
916-
]
917-
},
918-
"execution_count": 104,
919-
"metadata": {},
920-
"output_type": "execute_result"
921-
}
922-
],
899+
"outputs": [],
923900
"source": [
924901
"ki"
925902
]
926903
},
927904
{
928905
"cell_type": "code",
929-
"execution_count": 117,
906+
"execution_count": null,
930907
"id": "225bcac5",
931908
"metadata": {},
932909
"outputs": [],
@@ -936,21 +913,10 @@
936913
},
937914
{
938915
"cell_type": "code",
939-
"execution_count": 118,
916+
"execution_count": null,
940917
"id": "85d97205",
941918
"metadata": {},
942-
"outputs": [
943-
{
944-
"data": {
945-
"text/plain": [
946-
"[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]"
947-
]
948-
},
949-
"execution_count": 118,
950-
"metadata": {},
951-
"output_type": "execute_result"
952-
}
953-
],
919+
"outputs": [],
954920
"source": [
955921
"ku"
956922
]
@@ -964,6 +930,61 @@
964930
"source": [
965931
"kk=*"
966932
]
933+
},
934+
{
935+
"cell_type": "code",
936+
"execution_count": 6,
937+
"id": "e43bbfbc",
938+
"metadata": {},
939+
"outputs": [
940+
{
941+
"name": "stdout",
942+
"output_type": "stream",
943+
"text": [
944+
"['__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__ior__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']\n"
945+
]
946+
}
947+
],
948+
"source": [
949+
"print(dir(k))"
950+
]
951+
},
952+
{
953+
"cell_type": "code",
954+
"execution_count": 7,
955+
"id": "eb0d984f",
956+
"metadata": {},
957+
"outputs": [
958+
{
959+
"name": "stdout",
960+
"output_type": "stream",
961+
"text": [
962+
"enter your question: what is python\n",
963+
"enter your option: programming language, software, else , none \n",
964+
"{'question': 'what is python', 'option': 'programming language, software, else , none '}\n",
965+
"what is python\n",
966+
"programming language, software, else , none \n"
967+
]
968+
}
969+
],
970+
"source": [
971+
"s=['question','option']\n",
972+
"k=dict()\n",
973+
"for i in s:\n",
974+
" r=input(f'enter your {i}: ')\n",
975+
" k[i]=r\n",
976+
"print(k)\n",
977+
"print(k['question'])\n",
978+
"print(k['option'])"
979+
]
980+
},
981+
{
982+
"cell_type": "code",
983+
"execution_count": null,
984+
"id": "6b600be6",
985+
"metadata": {},
986+
"outputs": [],
987+
"source": []
967988
}
968989
],
969990
"metadata": {

something.ipynb

+48-5
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,27 @@
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 6,
60+
"execution_count": 4,
6161
"id": "7349bbf6",
6262
"metadata": {},
63-
"outputs": [],
63+
"outputs": [
64+
{
65+
"ename": "ValueError",
66+
"evalue": "dictionary update sequence element #0 has length 6; 2 is required",
67+
"output_type": "error",
68+
"traceback": [
69+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
70+
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
71+
"Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m question_bank\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;43mdict\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mquestion\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43moption\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mcurrect_ans\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mpoint\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m question_bank:\n\u001b[0;32m 3\u001b[0m i\u001b[38;5;241m=\u001b[39m\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mEnter your \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mi\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m: \u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
72+
"\u001b[1;31mValueError\u001b[0m: dictionary update sequence element #0 has length 6; 2 is required"
73+
]
74+
}
75+
],
6476
"source": [
65-
"question_bank={'question','option','currect_ans','point'}\n",
77+
"question_bank=dict({'question','option','currect_ans','point'})\n",
6678
"for i in question_bank:\n",
6779
" i=input(f'Enter your {i}: ')\n",
68-
" question_bank.setdefault(i)\n",
80+
" question_bank.append(i)\n",
6981
" print(question_bank)"
7082
]
7183
},
@@ -75,12 +87,43 @@
7587
"id": "c59e2405",
7688
"metadata": {},
7789
"outputs": [],
90+
"source": [
91+
"s=list()\n",
92+
"for i in range(3):\n",
93+
" k=input()\n",
94+
" s.append(k)\n",
95+
"print(k)"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": null,
101+
"id": "ba281319",
102+
"metadata": {},
103+
"outputs": [],
104+
"source": [
105+
"s=['question','option']\n",
106+
"k=dict()\n",
107+
"for i in s:\n",
108+
" r=input(f'enter your {i}: ')\n",
109+
" k[i]=r\n",
110+
"print(k)\n",
111+
"print(k['question'])\n",
112+
"print(k['option'])"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"id": "4a56517a",
119+
"metadata": {},
120+
"outputs": [],
78121
"source": []
79122
}
80123
],
81124
"metadata": {
82125
"kernelspec": {
83-
"display_name": "Python 3.9.12 ('base')",
126+
"display_name": "Python 3 (ipykernel)",
84127
"language": "python",
85128
"name": "python3"
86129
},

0 commit comments

Comments
 (0)