Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 88 additions & 4 deletions Notebook1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "73fb95c9",
"metadata": {},
"outputs": [
Expand All @@ -22,16 +22,100 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"id": "9d30ab5c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10.55\n"
]
}
],
"source": [
"#convert str to int\n",
"price_str = \"10.55\"\n",
"price_int = (price_str)\n",
"print(price_int)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "ca9af74b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{1, 2, 3, 4, 5}\n"
]
}
],
"source": [
"my_list = [1,2,3,4,5]\n",
"my_set = set(my_list)\n",
"\n",
"print(my_set)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "caf11966",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"80\n"
]
}
],
"source": [
"#convert str to float\n",
"price_str = \"80\"\n",
"price_float =(price_str)\n",
"print (price_float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aed75a98",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 39,
"id": "9386516d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"80\n"
]
}
],
"source": [
"#convert float to int\n",
"price_int = \"10.78\"\n",
"price_int = (price_float)\n",
"print (price_int)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "myenv",
"display_name": "pyt101 (3.13.12)",
"language": "python",
"name": "python3"
},
Expand All @@ -45,7 +129,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
"version": "3.13.12"
}
},
"nbformat": 4,
Expand Down
116 changes: 116 additions & 0 deletions python_10-3-26.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b95d1ce4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Result: 0.045454545454545456\n"
]
}
],
"source": [
"try:\n",
" a = int(input(\"Enter first value: \"))\n",
" b = int(input(\"Enter second value: \"))\n",
" \n",
" result = a / b\n",
" print(\"Result:\", result)\n",
"\n",
"except:\n",
" print(\"Error occurred during calculation\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9cebb24f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Result: 0.5\n"
]
}
],
"source": [
"try:\n",
" a = int(input(\"Enter first number: \"))\n",
" b = int(input(\"Enter second number: \"))\n",
" \n",
" print(\"Result:\", a / b)\n",
"\n",
"except ValueError:\n",
" print(\"Invalid number entered\")\n",
"\n",
"except ZeroDivisionError:\n",
" print(\"Division by zero is not allowed\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3ec6b04f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Result: 0.8\n"
]
}
],
"source": [
"try:\n",
" a = int(input(\"Enter first number: \"))\n",
" b = int(input(\"Enter second number: \"))\n",
" \n",
" result = a / b\n",
" print(\"Result:\", result)\n",
"\n",
"except ValueError:\n",
" print(\"Invalid input! Please enter numbers.\")\n",
"\n",
"except ZeroDivisionError:\n",
" print(\"Error! Division by zero.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2e2606c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pyt101 (3.13.12)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading