From 0c30f1d3a7067d3d034510dd3da3451b2a5f34db Mon Sep 17 00:00:00 2001
From: mohamedatef773mb <159392036+mohamedatef773mb@users.noreply.github.com>
Date: Sat, 10 Feb 2024 18:15:43 +0200
Subject: [PATCH] Add files via upload
---
Session2.ipynb | 1017 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1017 insertions(+)
create mode 100644 Session2.ipynb
diff --git a/Session2.ipynb b/Session2.ipynb
new file mode 100644
index 0000000..eb92d48
--- /dev/null
+++ b/Session2.ipynb
@@ -0,0 +1,1017 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "## List"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1-Type = \n",
+ "1-Type of item = \n",
+ "2-Use the index to get the value = 1\n",
+ "3-Change the value = [5, 2, 3, 4, 'amit', 'learing', True, 5]\n",
+ "4-Allow Duplicate Data [2, 2, 3, 4, 'amit', 'learing', True, 5]\n",
+ "5-List in the list [2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5]\n",
+ "6-Convert to list ['a', 'm', 'i', 't']\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 1-List can be represented by [ ]\n",
+ "List_one=[1,2,3,4,\"amit\",\"learing\",True,5]\n",
+ "print(\"1-Type = \",type(List_one))\n",
+ "print(\"1-Type of item = \",type(List_one[-1]))\n",
+ "# 2- Ordered can use the index \n",
+ "print(\"2-Use the index to get the value = \",List_one[0])\n",
+ "# 3-changeable Data \n",
+ "List_one[0]=5\n",
+ "print(\"3-Change the value = \",List_one)\n",
+ "# 4- Allow Duplicate Data \n",
+ "List_one[0]=2\n",
+ "List_one[1]=2\n",
+ "print(\"4-Allow Duplicate Data \",List_one)\n",
+ "# 5 you can have Lists within Lists \n",
+ "List_one[5]=[1,2,3,5,6,9]\n",
+ "print(\"5-List in the list\",List_one)\n",
+ "# 6 Convert any datatype to list Using List() function\n",
+ "y =list(\"amit\")\n",
+ "print('6-Convert to list ',y)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Some Functions "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### append "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Before = [2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5]\n",
+ "After = [2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Append(): Add the specified item to the end of the list.\n",
+ "print(\"Before = \",List_one)\n",
+ "List_one.append([1,2,3,4,5,6])\n",
+ "print(\"After = \",List_one)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### insert"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "before : [2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6]]\n",
+ "After : ['machine learning', 2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# insert(): adds the specified item at the given index in the list.\n",
+ "print(\"before :\",List_one)\n",
+ "List_one.insert(0,\"machine learning\")\n",
+ "print(\"After :\",List_one)\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### extend"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "before : ['machine learning', 2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6]]\n",
+ "After : ['machine learning', 2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6], 1, 2, 3, 4, 5, 6]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# extend(): adds elements from the iterable to the end of the list.\n",
+ "print(\"before :\",List_one)\n",
+ "List_one.extend([1,2,3,4,5,6])\n",
+ "print(\"After :\",List_one)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##### This is the difference between extend and append\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### remove"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "before : ['machine learning', 2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6], 1, 2, 3, 4, 5, 6]\n",
+ "After : [2, 2, 3, 4, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6], 1, 2, 3, 4, 5, 6]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# remove(): removes the first occurrence of the specified item from the list.\n",
+ "print(\"before :\",List_one)\n",
+ "List_one.remove(\"machine learning\")\n",
+ "print(\"After :\",List_one)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### pop"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "before ['amit', 'AI', 'pyhton']\n",
+ "return amit\n",
+ "After ['AI', 'pyhton']\n"
+ ]
+ }
+ ],
+ "source": [
+ "# pop(): removes and returns the item at the specified index in the list.\n",
+ "pop_one = ['amit', 'AI', 'pyhton']\n",
+ "print('before',pop_one)\n",
+ "print(\"return\",pop_one.pop(0))\n",
+ "print('After',pop_one)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### del"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "before : [2, 2, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6], 1, 2, 3, 4, 5, 6]\n",
+ "After : [2, 'amit', [1, 2, 3, 5, 6, 9], True, 5, [1, 2, 3, 4, 5, 6], 1, 2, 3, 4, 5, 6]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# del : removes the item at the specified index using the del statement\n",
+ "print(\"before :\",List_one)\n",
+ "del List_one[0]\n",
+ "print(\"After :\",List_one)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Different between pop and del\n",
+ "#### Pop returns returns the item while del no"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### index() count() sort() reverse() clear() "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "index is = 1\n",
+ "count is = 2\n",
+ "sortes is = [1, 2, 3, 4, 4, 5, 5, 6, 7]\n",
+ "reverse is = [7, 6, 5, 5, 4, 4, 3, 2, 1]\n",
+ "After clear = []\n"
+ ]
+ }
+ ],
+ "source": [
+ "# index() : Returns the index of the first occurrence of a specified value.\n",
+ "List_one.index(\"amit\")\n",
+ "print(\"index is = \",List_one.index(\"amit\"))\n",
+ "# count() : Returns the number of occurrences of a specified value.\n",
+ "List_two=[1,2,3,4,5,4,6,5,7]\n",
+ "print(\"count is = \",List_two.count(5))\n",
+ "# sort() : Sorts the list in ascending order.\n",
+ "List_two=[1,2,3,4,5,4,6,5,7]\n",
+ "List_two.sort()\n",
+ "print(\"sortes is = \",List_two)\n",
+ "List_two.reverse()\n",
+ "print(\"reverse is = \",List_two)\n",
+ "List_two.clear()\n",
+ "print(\"After clear = \",List_two)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Input fuction"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Ezz Ahmed\n"
+ ]
+ }
+ ],
+ "source": [
+ "name=input(\"enter your name\")\n",
+ "id=input(\"enter your id\")\n",
+ "print(name,id)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Tuple"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1-Type = \n",
+ "2- Use the index to get the value = 1\n",
+ "4-Allow Duplicate Data (1, 1, 1, 2, 2, 2, 2, 2)\n",
+ "5-List in the tupl ([1, 2, 3, 5, 6, 9], 6.87)\n",
+ "6-Convert to tuple ('a', 'm', 'i', 't')\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 1-Tuple can be represented by ( )\n",
+ "tuple_one =(1,2,3,4,5.5,4.5,\"amit\",'learning')\n",
+ "print(\"1-Type =\",type(tuple_one))\n",
+ "# 2- Ordered can use the index \n",
+ "print(\"2- Use the index to get the value = \",tuple_one[0])\n",
+ "\n",
+ "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",
+ "# 3- Unchangeable Data\n",
+ "# tuple_one[0]=5\n",
+ "# I can't change the value\n",
+ "\n",
+ "# 4. Allow Duplicate Data\n",
+ "tuple_two=(1,1,1,2,2,2,2,2)\n",
+ "print(\"4-Allow Duplicate Data \",tuple_two)\n",
+ "#5. Can be nested among all (you can have lists within lists.)\n",
+ "tuple_three=([1,2,3,5,6,9],6.87)\n",
+ "print(\"5-List in the tupl\",tuple_three)\n",
+ "# 6. Convert any datatype to list using Tuple() function\n",
+ "y =tuple(\"amit\")\n",
+ "print('6-Convert to tuple ',y)\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Note I can't use Functions like append or remove ...... etc why ?\n",
+ "### because tuple is unchange so to solve this problem you can convert from tuble to list\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Set"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1-Type = \n",
+ "4-doesn't Allow Duplicate Data {'amit', 'learning'}\n",
+ "6-Convert to tuple ('a', 'm', 'i', 't')\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 1-Set can be represented by { }\n",
+ "set_one={\"amit\",\"learning\"}\n",
+ "print(\"1-Type =\",type(set_one))\n",
+ "\n",
+ "# >>>>>>>>>>>>>>>>>>>>\n",
+ "# 2-Unordered\n",
+ "# give the error because i can't access the element\n",
+ "# set_one[0]\n",
+ "# >>>>>>>>>>>>>>>>>>\n",
+ "\n",
+ "\n",
+ "# >>>>>>>>>>>>>>>>>>>>\n",
+ "# 3.Unchangeable Data\n",
+ "# give the error because i can't change the element\n",
+ "# set_one[0]=5\n",
+ "# print(\"3-Change the value = \",set_one)\n",
+ "# >>>>>>>>>>>>>>>>>>\n",
+ "\n",
+ "\n",
+ "# 4. Not allow Duplicate Data\n",
+ "set_one={\"amit\",\"learning\",\"amit\"}\n",
+ "print(\"4-doesn't Allow Duplicate Data \",set_one)\n",
+ "\n",
+ "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",
+ "#5. Can not be nested among all (you can not have lists within lists.)\n",
+ "# give the error because i can't but the list\n",
+ "# set_one={\"amit\",\"learning\",\"amit\",{1,23,2,5}}\n",
+ "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",
+ "\n",
+ "\n",
+ "# 6. Convert any datatype to list using set() function\n",
+ "\n",
+ "y =tuple(\"amit\")\n",
+ "print('6-Convert to tuple ',y)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Dictionary"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "30"
+ ]
+ },
+ "execution_count": 68,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "x={10:\"learing\",10:5,3:\"learing\",True:3,10:30}\n",
+ "x[10]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "1-Type = \n",
+ "2-Use the index to get the value = 3\n",
+ "3-Change the value = {1: 3, 2: 'learing', 3: 'learing', 'Key1': 5}\n",
+ "4-Allow Duplicate Data {1: 3, 2: 'learing', 3: 'learing', 'Key1': 5}\n",
+ "5-List in the list {1: 3, 2: 'learing', 3: 'learing', 'Key1': [1, 2, 3, 4, 5, 6, 7]}\n",
+ "6- Convert to tuple {'a': 1, 'b': 2, 'c': 3}\n"
+ ]
+ }
+ ],
+ "source": [
+ "# 1-dictionary can be represented by { }\n",
+ "dic_one={1:\"Mohamed\",2:\"learing\",3:\"learing\",True:3,\"Key1\":30}\n",
+ "print(\"1-Type = \",type(dic_one))\n",
+ "# 2-ordered\n",
+ "print(\"2-Use the index to get the value = \",dic_one[True])\n",
+ "\n",
+ "# 3- changeable Data\n",
+ "dic_one[\"Key1\"]=5\n",
+ "print(\"3-Change the value = \",dic_one)\n",
+ "\n",
+ "# 4- allow Duplicate Data as value not as a key\n",
+ "print(\"4-Allow Duplicate Data \",dic_one)\n",
+ "\n",
+ "# 5 you can have Lists within dictionary\n",
+ "dic_one[\"Key1\"]=[1,2,3,4,5,6,7]\n",
+ "print(\"5-List in the list\",dic_one)\n",
+ "\n",
+ "\n",
+ "# 6 Convert any datatype to dictionary using dict() function\n",
+ "y =dict([('a',1),(\"b\",2),('c',3)])\n",
+ "print('6- Convert to tuple ',y)\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## if"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### if-condition"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "a is greater than b \n"
+ ]
+ }
+ ],
+ "source": [
+ "a=200\n",
+ "b=33\n",
+ "if b>a:\n",
+ " print(\"b is greater than a \")\n",
+ "else:\n",
+ " print(\"a is greater than b \")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### If-Condition With Logic Operations\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Both x and y are positive\n"
+ ]
+ }
+ ],
+ "source": [
+ "x=5\n",
+ "y=10\n",
+ "if x>0 and y>0:\n",
+ " print(\"Both x and y are positive\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "You are child\n"
+ ]
+ }
+ ],
+ "source": [
+ "age=15\n",
+ "if age<18 or age >=65:\n",
+ " print(\"You are child\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It's not raining . You can go outside\n"
+ ]
+ }
+ ],
+ "source": [
+ "is_raning=False\n",
+ "if not is_raning:\n",
+ " print(\"It's not raining . You can go outside\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### ShortHand If - Condition\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "15\n"
+ ]
+ }
+ ],
+ "source": [
+ "a=10\n",
+ "b=5\n",
+ "result= a+b if a>b else a-b\n",
+ "print(result)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Adult\n"
+ ]
+ }
+ ],
+ "source": [
+ "age=21\n",
+ "print(\"Adult\") if age>=18 else(print(\"Teenager\") if age>=13 else (print(\"Child\")))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Nested If - Condition\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "It's not a sunny day\n"
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "is_sunny =True\n",
+ "tep=25\n",
+ "if not is_sunny:\n",
+ " print(\"It's a sunny day !\")\n",
+ " if tep>20:\n",
+ " print(\"The weather is warm\")\n",
+ " else:\n",
+ " print(\"The weather is cool\")\n",
+ "else:\n",
+ " print(\"It's not a sunny day\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Loop"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### For loop"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "a\n",
+ "m\n",
+ "i\n",
+ "t\n"
+ ]
+ }
+ ],
+ "source": [
+ "for x in \"amit\":\n",
+ " print(x) "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "python\n",
+ "python\n",
+ "python\n",
+ "python\n",
+ "Loop finished\n"
+ ]
+ }
+ ],
+ "source": [
+ "for x in \"amit\":\n",
+ " print(\"python\")\n",
+ "else:\n",
+ " print(\"Loop finished\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "3\n",
+ "4\n",
+ "5\n",
+ "6\n",
+ "7\n",
+ "8\n",
+ "9\n"
+ ]
+ }
+ ],
+ "source": [
+ "for x in range(10):\n",
+ " print(x)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n",
+ "amit\n"
+ ]
+ }
+ ],
+ "source": [
+ "for x in range(10):\n",
+ " print(\"amit\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Break , Continue ,pass"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "4\n",
+ "5\n"
+ ]
+ }
+ ],
+ "source": [
+ "for i in range(6):\n",
+ " if i==3:\n",
+ " continue\n",
+ " print(i)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n"
+ ]
+ }
+ ],
+ "source": [
+ "for i in range(6):\n",
+ " if i==3:\n",
+ " break\n",
+ " print(i)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "3\n",
+ "4\n",
+ "5\n"
+ ]
+ }
+ ],
+ "source": [
+ "for i in range(6):\n",
+ " if i==3:\n",
+ " pass\n",
+ " print(i)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### while Loop"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "3\n",
+ "4\n",
+ "5\n"
+ ]
+ }
+ ],
+ "source": [
+ "x=0 \n",
+ "while x<6:\n",
+ " print(x)\n",
+ " x+=1"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "## Solve this problem"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "###### 85-100 A\n",
+ "###### 75-85 B\n",
+ "###### 65-75 C\n",
+ "###### 50-65 D\n",
+ "###### <50 F "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "invalid literal for int() with base 10: 'Mohamed'",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[1;32mIn[28], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m x\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43menter your grade \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m x\u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m85\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m x\u001b[38;5;241m<\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m100\u001b[39m:\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
+ "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'Mohamed'"
+ ]
+ }
+ ],
+ "source": [
+ "x=int(input('enter your grade '))\n",
+ "\n",
+ "if x>=85 and x<=100:\n",
+ " print('A')\n",
+ "elif x>=75 and x<85:\n",
+ " print('B')\n",
+ "elif x>=65 and x<75:\n",
+ " print('C')\n",
+ "elif x>=50 and x<65:\n",
+ " print('D')\n",
+ "elif x<50:\n",
+ " print('good luck next year')\n",
+ "else:\n",
+ " print('enter a valid data')\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "base",
+ "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.10.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}