diff --git a/Notebook1.ipynb b/Notebook1.ipynb index f080647..3fdf7e0 100644 --- a/Notebook1.ipynb +++ b/Notebook1.ipynb @@ -22,16 +22,180 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "ca9af74b", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "34.4\n", + "hello\n" + ] + } + ], + "source": [ + "# 3 variables of different data types \n", + "\n", + "a = 10\n", + "b = 34.4\n", + "c = \"hello\"\n", + "print(a)\n", + "print(b)\n", + "print(c)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "1bfb78dd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5]\n" + ] + } + ], + "source": [ + "list = [1, 2, 3, 4, 5]\n", + "print(list) \n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "6d2bdb01", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'name': 'Yash', 'age': 20, 'city': 'New York'}\n" + ] + } + ], + "source": [ + "dict = {\"name\": \"Yash\", \"age\": 20, \"city\": \"New York\"}\n", + "print(dict)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "8b4b5644", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "intiger variable a: 10\n", + "float variable b: 34.4\n", + "string variable c: hello\n", + "list variable list: [1, 2, 3, 4, 5]\n", + "dictionary variable dict: {'name': 'Yash', 'age': 20, 'city': 'New York'}\n" + ] + } + ], + "source": [ + "# printing the variables declared \n", + "print(\"intiger variable a:\", a)\n", + "print(\"float variable b:\", b)\n", + "print(\"string variable c:\", c)\n", + "print(\"list variable list:\", list)\n", + "print(\"dictionary variable dict:\", dict)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "581138df", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1, 2, 3, 4, 5}\n" + ] + } + ], + "source": [ + "list1 = [1, 2, 3, 4, 5, 1, 2, 3]\n", + "print(set(list1))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "ea61f92f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{1, 2, 3, 4, 5, 'b', 'a', 'c'}\n", + "(1, 2, 3, 4, 5, 'b', 'a', 'c')\n", + "19.99\n" + ] + } + ], + "source": [ + "list2 = [1, 2, 3, 4, 5 ,\"a\", \"b\", \"c\"]\n", + "print(set(list2))\n", + "print(tuple(set(list2)))\n", + "price_str = \"19.99\"\n", + "price_float = float(price_str)\n", + "print(price_float)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "085bdd85", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to the discount calculator!\n", + "total discount : 1050.0\n", + " total amount aften discount:5950.0\n" + ] + } + ], + "source": [ + "# create a CLI based discount calculator \n", + "print(\"Welcome to the discount calculator!\")\n", + "amount = float(input(\"Enter the original amount: \"))\n", + "if amount > 500:\n", + " discount = 0.15\n", + "\n", + "elif amount > 1000:\n", + " discount = 0.10\n", + "\n", + "elif amount > 5000:\n", + " discount = 0.06\n", + "\n", + "else:\n", + " print(\"invalid amount\")\n", + " \n", + "\n", + "print(f\"total discount : {discount*amount}\\n total amount aften discount:{amount-discount*amount}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "myenv", + "display_name": "base", "language": "python", "name": "python3" }, @@ -45,7 +209,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.7" + "version": "3.13.9" } }, "nbformat": 4, diff --git a/notebook12feb.ipynb b/notebook12feb.ipynb new file mode 100644 index 0000000..87edc79 --- /dev/null +++ b/notebook12feb.ipynb @@ -0,0 +1,37 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "0e705c85", + "metadata": {}, + "outputs": [], + "source": [ + "# create a CLI based discount calculator \n", + "print(\"Welcome to the discount calculator!\")\n", + "amount = float(input(\"Enter the original amount: \"))\n", + "if amount > 500:\n", + " discount = 0.15\n", + "\n", + "elif amount > 1000:\n", + " discount = 0.10\n", + "\n", + "elif amount > 5000:\n", + " discount = 0.06\n", + "\n", + "else:\n", + " print(\"invalid amount\")\n", + " \n", + "\n", + "print(f\"total discount : {discount*amount}\\n total amount aften discount:{amount-discount*amount}\")" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/python task 1/task1.ipynb b/python task 1/task1.ipynb new file mode 100644 index 0000000..f33dd87 --- /dev/null +++ b/python task 1/task1.ipynb @@ -0,0 +1,261 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "9019e3f5", + "metadata": {}, + "outputs": [], + "source": [ + "def numberspecification():\n", + " input1=int(input(\"enter a number between 1 to 10\"))\n", + " while input1!= 3:\n", + " if input1==1:\n", + " print(\"this is dog\")\n", + " \n", + " elif input1==2:\n", + " print(\"this is cat\") \n", + " \n", + " else:\n", + " print(\"This is not animal\")\n", + " break\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1c5df36", + "metadata": {}, + "outputs": [], + "source": [ + "numberspecification()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "0fcb9e6e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "eliment in 0 position of list : 1\n", + "eliment in 1 position of list : 2\n", + "eliment in 2 position of list : 3\n", + "eliment in 3 position of list : yash\n", + "eliment in 4 position of list : 45\n", + "eliment in 5 position of list : False\n", + "eliment in 6 position of list : True\n" + ] + } + ], + "source": [ + "list=[1,2,3,\"yash\",45,False,True]\n", + "number=len(list)\n", + "\n", + "for i in range(number):\n", + " print(f\"eliment in {i} position of list : {list[i]}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d80382c", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "20e0237d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "After sort() = [10, 20, 30, 40, 50]\n", + "After remove(30) = [10, 20, 40, 50]\n", + "After pop(1) = [10, 40, 50]\n" + ] + } + ], + "source": [ + "#use the sort(), remove(),pop(),funtion in the list of squares\n", + "# that you have created .\n", + "my_list = [10, 20, 30, 40, 50]\n", + "my_list.sort()\n", + "print(\"After sort() =\", my_list)\n", + "my_list.remove(30)\n", + "print(\"After remove(30) =\", my_list)\n", + "my_list.pop(1)\n", + "print(\"After pop(1) =\", my_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "166f6f5a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Item1: pen\n", + "Iteam2: pencil\n", + "iteam3: eraser\n" + ] + } + ], + "source": [ + "new_dict = {\"Item1\": \"pen\",\"Iteam2\": \"pencil\", \"iteam3\":\"eraser\"} \n", + "\n", + "for i,j in new_dict.items():\n", + " \n", + " print(f\"{i}: {j}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "33a323df", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "2\n", + "3\n", + "iteam found\n", + "66\n", + "74\n", + "84\n", + "87\n", + "90\n" + ] + } + ], + "source": [ + "# define a list and define a variable name search item\n", + "list=[1,2,3,45,66,74,84,87,90]\n", + "search_iteam=45\n", + "for i in list:\n", + " if i==search_iteam:\n", + " print(\"iteam found\")\n", + " # break\n", + " continue\n", + " else:\n", + " print(i)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "58cd1127", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['4']\n", + "[45, '4']\n", + "[45, '4', 1, 2, 3]\n" + ] + } + ], + "source": [ + "l=[]\n", + "\n", + "input1=input(\"enter a number\")\n", + "\n", + "l.append(input1)\n", + " \n", + "print(l)\n", + "\n", + "\n", + "l.insert(0,45)\n", + "print(l)\n", + "\n", + "l.extend([1,2,3])\n", + "print(l)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "18af1aae", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "List of squares = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]\n" + ] + } + ], + "source": [ + "# populate the list with the squre of the number between 1-12\n", + "list = []\n", + "for num in range (1,13):\n", + " square = num * num\n", + " list.append(square)\n", + "\n", + "# display result\n", + "print(\"List of squares =\", list)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "50c4dd86", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list_of_sqr = [x * x for x in range(1,13)]\n", + "list_of_sqr\n", + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "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 +}