├── Day 11 ├── test.py └── day11.ipynb ├── Day 10 ├── my.py └── NoteBook10.py ├── Day 15 ├── a.py ├── b.py ├── mypack │ ├── myasterisc.py │ └── __pycache__ │ │ └── myasterisc.cpython-310.pyc ├── mymain.py ├── __pycache__ │ ├── a.cpython-310.pyc │ ├── b.cpython-310.pyc │ └── myasterisc.cpython-310.pyc └── pc.txt ├── ss.png ├── Day 01 ├── 1.Python (1).pdf ├── 2.Creating Variables (1).pdf └── NoteBook1.ipynb ├── NOTES PDF ├── 1.Python.pdf └── 2.Creating Variables.pdf ├── README.md ├── Day 19 └── NoteBook19.py ├── Day 20 ├── NoteBook20.py └── day20r.py ├── Day 23 └── NoteBookUI23.py ├── Day 21 ├── day21.py └── NoteBook21.ipynb ├── Day 22 └── NoteBook22.py ├── LICENSE ├── Day 24 └── Project.py ├── Day 18 └── NoteBook18.py ├── Day 17 └── NoteBook17.py ├── Day 14 └── NoteBook14.ipynb ├── Day 09 ├── NoteBook9.ipynb └── Day 9 (Solution).ipynb ├── Day 16 └── Project01.ipynb ├── Day 06 ├── NoteBook6.ipynb └── Day 6 (Solution).ipynb ├── Day 03 └── Notebook3.ipynb ├── Day 04 ├── Notebook4.ipynb └── Day 4 (Solution).ipynb ├── Day 02 ├── Day 2 (Solution).ipynb └── Notebook2.ipynb ├── Day 05 ├── Notebook5.ipynb └── Day 5 (Solution).ipynb ├── Day 08 ├── NoteBook8.ipynb └── Day 8 (Solution).ipynb ├── Day 12 └── NoteBook12.ipynb ├── Day 07 ├── NoteBook7.ipynb └── Day 7 (Solution).ipynb └── Day 13 └── NoteBook13.ipynb /Day 11/test.py: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /Day 10/my.py: -------------------------------------------------------------------------------- 1 | a=10 2 | print(aiter) -------------------------------------------------------------------------------- /Day 15/a.py: -------------------------------------------------------------------------------- 1 | def add(): 2 | print("Add = ",10+20) 3 | -------------------------------------------------------------------------------- /Day 15/b.py: -------------------------------------------------------------------------------- 1 | def sub(): 2 | print("Sub = ",20-10) 3 | -------------------------------------------------------------------------------- /Day 15/mypack/myasterisc.py: -------------------------------------------------------------------------------- 1 | def mul(): 2 | print("Mul = ",20*10) 3 | -------------------------------------------------------------------------------- /ss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/ss.png -------------------------------------------------------------------------------- /Day 01/1.Python (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 01/1.Python (1).pdf -------------------------------------------------------------------------------- /NOTES PDF/1.Python.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/NOTES PDF/1.Python.pdf -------------------------------------------------------------------------------- /Day 15/mymain.py: -------------------------------------------------------------------------------- 1 | import a,b 2 | 3 | import myasterisc as ast 4 | 5 | print("i am mymain") 6 | a.add() 7 | b.sub() 8 | ast.mul() -------------------------------------------------------------------------------- /NOTES PDF/2.Creating Variables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/NOTES PDF/2.Creating Variables.pdf -------------------------------------------------------------------------------- /Day 01/2.Creating Variables (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 01/2.Creating Variables (1).pdf -------------------------------------------------------------------------------- /Day 15/__pycache__/a.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 15/__pycache__/a.cpython-310.pyc -------------------------------------------------------------------------------- /Day 15/__pycache__/b.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 15/__pycache__/b.cpython-310.pyc -------------------------------------------------------------------------------- /Day 15/__pycache__/myasterisc.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 15/__pycache__/myasterisc.cpython-310.pyc -------------------------------------------------------------------------------- /Day 15/mypack/__pycache__/myasterisc.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandrakant22/Python-3-MasterClass/HEAD/Day 15/mypack/__pycache__/myasterisc.cpython-310.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-3-MasterClass 2 | Learn from zero to hero with chandrakant sir

3 | Python 3 MasterClass Syllabus : 4 | Link

5 | ss 6 | 7 | -------------------------------------------------------------------------------- /Day 19/NoteBook19.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def funA(self): 3 | print("Hello") 4 | 5 | class B: 6 | def funB(self): 7 | print("Bye") 8 | 9 | 10 | class C(B,A): 11 | def myfun(self): 12 | print("hi") 13 | 14 | 15 | c =C() 16 | 17 | c.funA() 18 | c.funB() 19 | c.myfun() 20 | -------------------------------------------------------------------------------- /Day 10/NoteBook10.py: -------------------------------------------------------------------------------- 1 | #Loop 2 | #while 3 | #for 4 | 5 | #break 6 | #continue 7 | 8 | 9 | 10 | 11 | class Student: 12 | 13 | roll=0 14 | name="" 15 | p1=0.0 16 | p2=0.0 17 | p3=0.0 18 | 19 | def myfun(self): 20 | print("hello Student") 21 | 22 | 23 | def show(self): 24 | print(self.roll," ",self.name," ",self.p1+self.p2+self.p3) 25 | 26 | 27 | s= Student() 28 | s.myfun() 29 | s.roll=101 30 | print("roll ",s.roll) 31 | -------------------------------------------------------------------------------- /Day 20/NoteBook20.py: -------------------------------------------------------------------------------- 1 | # Python has three types of access modifiers: 2 | 3 | # Public Access Modifier self.a 4 | # Protected Access Modifier self._a 5 | # Private Access Modifier self.__a 6 | 7 | class Test: 8 | __pass="" 9 | 10 | def setPass(self,p): 11 | self.__pass=p 12 | 13 | def getPass(self): 14 | return self.__pass 15 | 16 | 17 | t=Test() 18 | 19 | t.__pass="abbc123" 20 | 21 | # t.setPass("abc123") 22 | 23 | print(t.__pass) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Day 20/day20r.py: -------------------------------------------------------------------------------- 1 | #Poly morphism 2 | 3 | 4 | class Bank: 5 | def rateofIntrest(self): 6 | print("9%") 7 | 8 | class SBI(Bank): 9 | def rateofIntrest(self): 10 | print("8%") 11 | 12 | class IDBI(Bank): 13 | def rateofIntrest(self): 14 | print("7.5%") 15 | 16 | class HDFC(Bank): 17 | def rateofIntrest(self): 18 | print("7%") 19 | 20 | class Yes(HDFC): 21 | pass 22 | 23 | s=SBI() 24 | s.rateofIntrest() 25 | 26 | i=IDBI() 27 | i.rateofIntrest() 28 | 29 | h=HDFC() 30 | h.rateofIntrest() 31 | 32 | y=Yes() 33 | y.rateofIntrest() -------------------------------------------------------------------------------- /Day 23/NoteBookUI23.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | t = Tk() 4 | t.geometry("300x100") 5 | t.title("Asterisc") 6 | 7 | def show_entry_fields(): 8 | print("First Name: %s" % (e1.get())) 9 | str_var.set("Welcome %s" % (e1.get())) 10 | 11 | def hiclick(): 12 | str_var.set("Welcome Student!") 13 | 14 | 15 | def byeclick(): 16 | str_var.set("Bye Student!") 17 | 18 | 19 | btn=Button(t,text="Hello",command = show_entry_fields) 20 | btn.place(x=90,y=50) 21 | 22 | btn=Button(t,text="Bye",command = byeclick) 23 | btn.place(x=160,y=50) 24 | 25 | e1=Entry(t) 26 | e1.place(x=10,y=10) 27 | 28 | str_var = StringVar() 29 | 30 | str_var.set("") 31 | 32 | l=Label(t,textvariable=str_var) 33 | l.place(x=100,y=20) 34 | 35 | 36 | t.mainloop() 37 | -------------------------------------------------------------------------------- /Day 21/day21.py: -------------------------------------------------------------------------------- 1 | #Abstraction in Python 2 | 3 | class SmartCar: 4 | def autoDriver(self): 5 | pass 6 | 7 | def smartAI(self): 8 | pass 9 | 10 | class Audi(SmartCar): 11 | def autoDriver(self): 12 | print("Audi Smart Car Running Automatic") 13 | 14 | def smartAI(self): 15 | print("Audi HAve omi Smart AI") 16 | 17 | 18 | class Bmw(SmartCar): 19 | def autoDriver(self): 20 | print("BMW Smart Car Running Automatic with 4 wheel Drive") 21 | 22 | def smartAI(self): 23 | print("BMW HAve roni Smart AI") 24 | 25 | def smartCCTV(self): 26 | print("BMW have BMW CCTV camera") 27 | 28 | 29 | 30 | sl100=Audi() 31 | sl100.smartAI() 32 | sl100.autoDriver() 33 | 34 | b400=Bmw() 35 | 36 | b400.autoDriver() 37 | b400.smartAI() 38 | b400.smartCCTV() -------------------------------------------------------------------------------- /Day 22/NoteBook22.py: -------------------------------------------------------------------------------- 1 | import mysql.connector as mysql 2 | 3 | mysqldb=mysql.connect( 4 | host="localhost", 5 | user="root", 6 | password="abc123", 7 | charset='utf8', 8 | database="mydb") 9 | 10 | cr=mysqldb.cursor() 11 | 12 | name=input("enter your good name") 13 | address=input("enter your Address") 14 | 15 | # sql = "insert into emp (name, address) values( %s, %s)" 16 | # val=(name,address) 17 | 18 | sql="delete from emp where name='om'" 19 | cr.execute(sql) 20 | 21 | mysqldb.commit() 22 | 23 | print("Data Inserted!!") 24 | print("done") 25 | 26 | 27 | 28 | # cr.execute("create database mydb") 29 | # cr.execute("create table emp(id int,name varchar(45),address varchar(255))") 30 | # sql = "insert into emp (name, address) values( %s, %s)" 31 | # val=[ 32 | # ("sham","pune"), 33 | # ("geeta","nagpur"), 34 | # ("om","pune"), 35 | # ("pooja","nagpur") 36 | # ] 37 | 38 | 39 | a=20 40 | a=30 41 | print(a) 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Chandrakant Bobade 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Day 24/Project.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import mysql.connector as mysql 3 | 4 | 5 | def myinsert(): 6 | 7 | db=mysql.connect( 8 | host="localhost", 9 | user="root", 10 | password="abc123", 11 | charset='utf8', 12 | database="mydb") 13 | 14 | cr=db.cursor() 15 | sql="INSERT INTO emp (id, name, address) VALUES (%s, %s, %s)" 16 | 17 | # id=eID.get() 18 | val = (eID.get(),eName.get(),eAddress.get()) 19 | 20 | cr.execute(sql,val) 21 | 22 | db.commit() 23 | # print("db :",db) 24 | txt.set("Data Inserted! ") 25 | 26 | # print("your Data",eID.get(),eName.get(),eAddress.get()) 27 | eID.set("") 28 | eName.set("") 29 | eAddress.set("") 30 | 31 | 32 | 33 | 34 | t=Tk() 35 | 36 | txt = StringVar() 37 | eID= StringVar() 38 | eName = StringVar() 39 | eAddress = StringVar() 40 | 41 | t.geometry("300x200") 42 | 43 | i=Label(t,text="Id :").grid(row=0,column=0) 44 | e=Entry(t,textvariable=eID).grid(row=0,column=1) 45 | 46 | i1=Label(t,text="Name :").grid(row=1,column=0) 47 | e1=Entry(t,textvariable=eName).grid(row=1,column=1) 48 | 49 | i1=Label(t,text="Address :").grid(row=2,column=0) 50 | e1=Entry(t,textvariable=eAddress).grid(row=2,column=1) 51 | 52 | bInsert=Button(t, text = "insert",command=myinsert).grid(row = 3, column = 0) 53 | 54 | 55 | i3=Label(t,textvariable=txt).grid(row=3,column=1) 56 | 57 | t.mainloop() 58 | -------------------------------------------------------------------------------- /Day 15/pc.txt: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import mysql.connector 3 | 4 | mydb = mysql.connector.connect( 5 | host="localhost", 6 | user="root", 7 | password="abc123", 8 | database="mydb" 9 | ) 10 | 11 | def update(): 12 | pass 13 | def delete(): 14 | pass 15 | 16 | t = Tk() 17 | 18 | var_id=StringVar() 19 | var_name=StringVar() 20 | var_address=StringVar() 21 | 22 | def myinsert(): 23 | 24 | id=var_id.get() 25 | name=var_name.get() 26 | address=var_address.get() 27 | 28 | mycursor = mydb.cursor() 29 | 30 | sql = "INSERT INTO student (id, full_name, address) VALUES (%s, %s, %s)" 31 | val = (id,name,address) 32 | 33 | mycursor.execute(sql, val) 34 | mydb.commit() 35 | print("hello ",id,name,address) 36 | 37 | 38 | from tkinter import * 39 | t = Tk() 40 | 41 | id = Label(t,text = "ID").grid(row = 0, column = 0) 42 | e2 = Entry(t,textvariable =var_id).grid(row = 0, column = 1) 43 | name = Label(t,text = "Name").grid(row = 1, column = 0) 44 | e1 = Entry(t,textvariable =var_name).grid(row = 1, column = 1) 45 | password = Label(t,text = "Address").grid(row = 2, column = 0) 46 | e2 = Entry(t,textvariable =var_address).grid(row = 2, column = 1) 47 | 48 | Button(t, text = "insert", command=myinsert).grid(row = 4, column = 0) 49 | update = Button(t, text = "update",command="update").grid(row = 4, column = 1) 50 | delete = Button(t, text = "delete", command="delete").grid(row = 4, column = 2) 51 | 52 | 53 | t.mainloop() 54 | print(mydb) -------------------------------------------------------------------------------- /Day 18/NoteBook18.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self): 3 | self.name="" 4 | self.address="" 5 | self.mobile="" 6 | 7 | def setData(self): 8 | self.name=input("Enter your name ") 9 | self.address=input("Enter your Address ") 10 | self.mobile=input("Enter your mobile number ") 11 | 12 | def show(self): 13 | print("Your name :",self.name) 14 | print("Your address :",self.address) 15 | print("Your mobile :",self.mobile) 16 | 17 | class Student(Person): 18 | def __init__(self): 19 | self.roll="" 20 | 21 | def setStudentData(self): 22 | print("Enter Data for Student") 23 | self.roll=input("Enter your roll ") 24 | Person.setData(self) 25 | 26 | def showStudent(self): 27 | print("Roll :",self.roll) 28 | Person.show(self) 29 | 30 | class Emp(Person): 31 | def __init__(self): 32 | self.empID="" 33 | 34 | def setEmpData(self): 35 | print("Enter Data for Emp") 36 | self.empID=input("Enter your EmpID ") 37 | Person.setData(self) 38 | 39 | def showEmp(self): 40 | print("Roll :",self.empID) 41 | Person.show(self) 42 | 43 | 44 | s=Student() 45 | s.setStudentData() #roll 46 | #s.setData() #name address mobile 47 | 48 | s.showStudent() 49 | #s.show() 50 | 51 | e=Emp() 52 | e.setEmpData() #roll 53 | #s.setData() #name address mobile 54 | 55 | e.showEmp() 56 | 57 | 58 | # p=Person() 59 | # p.setData() 60 | # p.show() 61 | 62 | -------------------------------------------------------------------------------- /Day 17/NoteBook17.py: -------------------------------------------------------------------------------- 1 | # Python Constructors 2 | # Python Constructor. A constructor is a special type of method (function) 3 | # which is used to initialize the instance members of the class. 4 | # default 5 | # parameterized 6 | 7 | class Student: 8 | roll=None 9 | name=None 10 | p1=0 11 | p2=0 12 | p3=0 13 | 14 | def __init__(self): 15 | print("hey i am const") 16 | self.roll=999 17 | self.name="not set" 18 | self.p1=0 19 | self.p2=0 20 | self.p3=0 21 | 22 | def __init__(self,roll,name,p1,p2,p3): 23 | self.roll=roll 24 | self.name=name 25 | self.p1=p1 26 | self.p2=p2 27 | self.p3=p3 28 | 29 | def __init__(self,roll,name): 30 | self.roll=roll 31 | self.name=name 32 | 33 | 34 | def setStudentData(self,roll,name,p1,p2,p3): 35 | self.roll=roll 36 | self.name=name 37 | self.p1=p1 38 | self.p2=p2 39 | self.p3=p3 40 | 41 | def showStudentData(self): 42 | print("Roll :",self.roll) 43 | print("Name :",self.name) 44 | print("Result :",self.p1 +self.p2+self.p3) 45 | 46 | 47 | 48 | 49 | s= Student(101,"geeta",20,20,20) 50 | s.showStudentData() 51 | 52 | s1= Student(101,"geeta") 53 | s1.showStudentData() 54 | 55 | 56 | # s.setStudentData(101,"ram",10,10,10) 57 | # s.showStudentData() 58 | 59 | 60 | # s1=Student() 61 | # s1.setStudentData(102,"sham",20,20,20) 62 | # s1.showStudentData() 63 | 64 | 65 | # s2=Student() 66 | # s2.showStudentData() 67 | # print(s.roll) 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Day 14/NoteBook14.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 6, 6 | "id": "114ccbdb", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "Enter any number6\n", 14 | "6 != 720\n" 15 | ] 16 | } 17 | ], 18 | "source": [ 19 | "def fact(n):\n", 20 | " if n == 1:\n", 21 | " return n\n", 22 | " else:\n", 23 | " return n*fact(n-1)\n", 24 | "x=int(input(\"Enter any number\"))\n", 25 | "if x<0:\n", 26 | " print(\"Not possible\")\n", 27 | "elif x==0:\n", 28 | " print(\"0! = 1\")\n", 29 | "else:\n", 30 | " f=fact(x)\n", 31 | " print(x,\"!=\",f)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "id": "5de091d0", 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "id": "69c1ce3c", 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [] 49 | } 50 | ], 51 | "metadata": { 52 | "kernelspec": { 53 | "display_name": "Python 3 (ipykernel)", 54 | "language": "python", 55 | "name": "python3" 56 | }, 57 | "language_info": { 58 | "codemirror_mode": { 59 | "name": "ipython", 60 | "version": 3 61 | }, 62 | "file_extension": ".py", 63 | "mimetype": "text/x-python", 64 | "name": "python", 65 | "nbconvert_exporter": "python", 66 | "pygments_lexer": "ipython3", 67 | "version": "3.10.3" 68 | } 69 | }, 70 | "nbformat": 4, 71 | "nbformat_minor": 5 72 | } 73 | -------------------------------------------------------------------------------- /Day 21/NoteBook21.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 13, 6 | "id": "de462f99", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "Enter any number1 sdfdfv\n" 14 | ] 15 | }, 16 | { 17 | "ename": "ValueError", 18 | "evalue": "invalid literal for int() with base 10: 'sdfdfv'", 19 | "output_type": "error", 20 | "traceback": [ 21 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 22 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 23 | "Input \u001b[1;32mIn [13]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m a\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 any number1 \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 b\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mint\u001b[39m(\u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEnter any number2 \u001b[39m\u001b[38;5;124m\"\u001b[39m))\n\u001b[0;32m 3\u001b[0m c\u001b[38;5;241m=\u001b[39ma\u001b[38;5;241m/\u001b[39mb\n", 24 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'sdfdfv'" 25 | ] 26 | } 27 | ], 28 | "source": [ 29 | "a=int(input(\"Enter any number1 \"))\n", 30 | "b=int(input(\"Enter any number2 \"))\n", 31 | "c=a/b\n", 32 | "\n", 33 | "print(\"Result =\",c)\n", 34 | "print(\"hello dear student\")\n" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 16, 40 | "id": "82a837d7", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "name": "stdout", 45 | "output_type": "stream", 46 | "text": [ 47 | "Enter any number1 xcfvdxfg\n", 48 | "Code 777 Error input int only\n", 49 | "hello dear student\n" 50 | ] 51 | } 52 | ], 53 | "source": [ 54 | "try:\n", 55 | " a=int(input(\"Enter any number1 \"))\n", 56 | " b=int(input(\"Enter any number2 \"))\n", 57 | " c=a/b\n", 58 | " print(\"Result =\",c)\n", 59 | "except ZeroDivisionError:\n", 60 | " print(\"Code 222 Error / by zero\")\n", 61 | "except ValueError:\n", 62 | " print(\"Code 777 Error input int only\")\n", 63 | "else:\n", 64 | " print(\"Code 333\")\n", 65 | " \n", 66 | "print(\"hello dear student\")" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "id": "9ba344c6", 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [] 76 | } 77 | ], 78 | "metadata": { 79 | "kernelspec": { 80 | "display_name": "Python 3 (ipykernel)", 81 | "language": "python", 82 | "name": "python3" 83 | }, 84 | "language_info": { 85 | "codemirror_mode": { 86 | "name": "ipython", 87 | "version": 3 88 | }, 89 | "file_extension": ".py", 90 | "mimetype": "text/x-python", 91 | "name": "python", 92 | "nbconvert_exporter": "python", 93 | "pygments_lexer": "ipython3", 94 | "version": "3.10.3" 95 | } 96 | }, 97 | "nbformat": 4, 98 | "nbformat_minor": 5 99 | } 100 | -------------------------------------------------------------------------------- /Day 09/NoteBook9.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "8427b0c7", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python If ... Else" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "19dace06", 14 | "metadata": {}, 15 | "source": [ 16 | "Python Conditions and If statements" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": null, 22 | "id": "e0b12746", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "id": "bea509c4", 30 | "metadata": {}, 31 | "source": [ 32 | "# if" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "id": "21d3d00c", 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "id": "b87357a1", 46 | "metadata": {}, 47 | "source": [ 48 | "# else" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "id": "af778f94", 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "id": "70086dd2", 62 | "metadata": {}, 63 | "source": [ 64 | "# elif" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "id": "f76290f2", 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "id": "c774b1a4", 78 | "metadata": {}, 79 | "source": [ 80 | "# Short Hand If" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "id": "a7b31d8b", 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "id": "f37d78c6", 94 | "metadata": {}, 95 | "source": [ 96 | "# Short Hand If ... Else" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": null, 102 | "id": "330f57fc", 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [] 106 | }, 107 | { 108 | "cell_type": "markdown", 109 | "id": "3734b08d", 110 | "metadata": {}, 111 | "source": [ 112 | "# logical operator -> and , or " 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "id": "f257632a", 119 | "metadata": {}, 120 | "outputs": [], 121 | "source": [] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "id": "40d670b1", 126 | "metadata": {}, 127 | "source": [ 128 | "# Nested If" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "id": "8ce3da53", 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "id": "5e04f2cd", 142 | "metadata": {}, 143 | "source": [ 144 | "# -------------------------------------Page End-------------------------------------\n", 145 | "Asterisc.in \n", 146 | "We will help you bring out the best in you...!! \n", 147 | "Industrial Training / Internship / College Projects\n", 148 | "Contact 7744822228 / 7743822228 \n", 149 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "id": "eb1d13fa", 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [] 159 | } 160 | ], 161 | "metadata": { 162 | "kernelspec": { 163 | "display_name": "Python 3 (ipykernel)", 164 | "language": "python", 165 | "name": "python3" 166 | }, 167 | "language_info": { 168 | "codemirror_mode": { 169 | "name": "ipython", 170 | "version": 3 171 | }, 172 | "file_extension": ".py", 173 | "mimetype": "text/x-python", 174 | "name": "python", 175 | "nbconvert_exporter": "python", 176 | "pygments_lexer": "ipython3", 177 | "version": "3.9.7" 178 | } 179 | }, 180 | "nbformat": 4, 181 | "nbformat_minor": 5 182 | } 183 | -------------------------------------------------------------------------------- /Day 16/Project01.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "f24ac8eb", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "lp=1\n", 11 | "total=40\n", 12 | "name=\"\"\n", 13 | "sa=0\n", 14 | "\n", 15 | "def userName():\n", 16 | " global name\n", 17 | " name=input(\"Enter your name :\")\n", 18 | " #print(\"welcome\",name)\n", 19 | "\n", 20 | "def printNotes(m):\n", 21 | " a=[500,100,50,20,10,5,2,1]\n", 22 | " temp=0\n", 23 | " i=0; \n", 24 | " temp=m;\n", 25 | " for i in range(0,8):\n", 26 | " if int(temp/a[i]) != 0 :\n", 27 | " print(a[i],\" notes is:\",int(temp/a[i]))\n", 28 | " temp=temp%a[i]\n", 29 | " \n", 30 | "def takeCash():\n", 31 | " cash=int(input(\"Enter your Cash :\"))\n", 32 | " #print(\"\\b/-\")\n", 33 | " global total\n", 34 | " if cash>total :\n", 35 | " printNotes(cash-total)\n", 36 | " \n", 37 | " elif cash Ordered\n", 13 | "2> immutable / Unchangeable\n", 14 | "3> () or tuple()\n", 15 | "4> Allow Duplicate" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "id": "578206a9", 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "id": "3ea6bf4a", 29 | "metadata": {}, 30 | "source": [ 31 | "# Access Items\n", 32 | "\n", 33 | "Indexing [1]\n", 34 | "Negative Indexing [-1]\n", 35 | "\n", 36 | "# Slicing\n", 37 | "\n", 38 | "Range of Indexes [2:5]\n", 39 | "Range of Negative Indexes[-4:-1]\n", 40 | "\n", 41 | "# Check\n", 42 | "\n", 43 | "Check if Item Exists --> in" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "id": "df006ac2", 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "4e558a14", 57 | "metadata": {}, 58 | "source": [ 59 | "# Tuples Methods" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "id": "9f78ab61", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "tuple(iterable) # many items a list has" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "id": "67079839", 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "id": "7a78ea44", 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "count(value) # Returns the count of given element" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": null, 93 | "id": "682fe697", 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "id": "b5b53ed8", 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "index(element) # Returns the index of the first matched item " 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "id": "ceced2ee", 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "id": "bb373e1e", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "min(tuple) # return the minimum element in tuple" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "id": "e9139334", 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "id": "5f3653ad", 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "max(tuple) # return the maximum element in tuple" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "id": "bf227d3b", 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "id": "6555ae7a", 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "del(tuple) # Removes all the elements from the tuple" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "id": "d08870fb", 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "id": "01fc1e95", 174 | "metadata": {}, 175 | "outputs": [], 176 | "source": [ 177 | "sum(tuple) # Sum of numbers in the Tuple" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "id": "6dbfe0bf", 184 | "metadata": {}, 185 | "outputs": [], 186 | "source": [] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "id": "9a9ad437", 191 | "metadata": {}, 192 | "source": [ 193 | "# -------------------------------------Page End-------------------------------------\n", 194 | "Asterisc.in \n", 195 | "We will help you bring out the best in you...!! \n", 196 | "Industrial Training / Internship / College Projects\n", 197 | "Contact 7744822228 / 7743822228 \n", 198 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 199 | ] 200 | } 201 | ], 202 | "metadata": { 203 | "kernelspec": { 204 | "display_name": "Python 3 (ipykernel)", 205 | "language": "python", 206 | "name": "python3" 207 | }, 208 | "language_info": { 209 | "codemirror_mode": { 210 | "name": "ipython", 211 | "version": 3 212 | }, 213 | "file_extension": ".py", 214 | "mimetype": "text/x-python", 215 | "name": "python", 216 | "nbconvert_exporter": "python", 217 | "pygments_lexer": "ipython3", 218 | "version": "3.10.3" 219 | } 220 | }, 221 | "nbformat": 4, 222 | "nbformat_minor": 5 223 | } 224 | -------------------------------------------------------------------------------- /Day 03/Notebook3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "16094543", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Operators\n", 9 | "\n", 10 | "An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation\n", 11 | "\n", 12 | "#following groups:\n", 13 | "\n", 14 | "1. Arithmetic operators\n", 15 | "2. Assignment operators\n", 16 | "3. Comparison operators\n", 17 | "4. Logical operators\n", 18 | "5. Identity operators\n", 19 | "6. Membership operators\n", 20 | "7. Bitwise operators" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "id": "93235cca", 26 | "metadata": {}, 27 | "source": [ 28 | "# 1. Arithmetic operators\n", 29 | "\n", 30 | "Arithmetic operators are used with numeric values to perform common mathematical operations:" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "id": "dd946842", 36 | "metadata": {}, 37 | "source": [ 38 | "Addition + \n", 39 | "Subtraction - \n", 40 | "Multiplication *\n", 41 | "Division /\n", 42 | "Modulus %\n", 43 | "Exponentiation **\n", 44 | "\n", 45 | "Floor division // [ the floor division // rounds the result down to the nearest whole number ]" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "id": "bbc5696a", 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "x=15\n", 56 | "y=2" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "id": "dc947c24", 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "id": "f6474c24", 70 | "metadata": {}, 71 | "source": [ 72 | "# Python Assignment Operators\n", 73 | "\n", 74 | "= += -= *= /= %= //= **= " 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "id": "7456f8c4", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "id": "1bc45c9d", 88 | "metadata": {}, 89 | "source": [ 90 | "# Python Comparison Operators\n", 91 | "\n", 92 | "== != > < >= <=" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "85dc56a0", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "id": "74bb7cdc", 106 | "metadata": {}, 107 | "source": [ 108 | "# Python Logical Operators\n", 109 | "\n", 110 | "and | or | not" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": null, 116 | "id": "8fec4cf6", 117 | "metadata": {}, 118 | "outputs": [], 119 | "source": [] 120 | }, 121 | { 122 | "cell_type": "markdown", 123 | "id": "1fc54253", 124 | "metadata": {}, 125 | "source": [ 126 | "# Python Identity Operators\n", 127 | "\n", 128 | "used to compare the objects\n", 129 | "\n", 130 | "is | is not " 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 1, 136 | "id": "42c9e38d", 137 | "metadata": {}, 138 | "outputs": [], 139 | "source": [ 140 | "x = []\n", 141 | "y = []\n", 142 | "z = x" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 3, 148 | "id": "dfd936f1", 149 | "metadata": {}, 150 | "outputs": [ 151 | { 152 | "data": { 153 | "text/plain": [ 154 | "True" 155 | ] 156 | }, 157 | "execution_count": 3, 158 | "metadata": {}, 159 | "output_type": "execute_result" 160 | } 161 | ], 162 | "source": [] 163 | }, 164 | { 165 | "cell_type": "markdown", 166 | "id": "50a1611b", 167 | "metadata": {}, 168 | "source": [ 169 | "# Python Membership Operators\n", 170 | "\n", 171 | "used to test if a sequence is presented in an object:\n", 172 | "\n", 173 | "in | not in" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "id": "c8477be2", 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [] 183 | }, 184 | { 185 | "cell_type": "markdown", 186 | "id": "65e540e7", 187 | "metadata": {}, 188 | "source": [ 189 | "# Python Bitwise Operators\n", 190 | "\n", 191 | "Bitwise operators are used to compare (binary) numbers:\n", 192 | "\n", 193 | "AND & \n", 194 | "OR | \n", 195 | "XOR ^ \n", 196 | "NOT ~ \n", 197 | "Left shift <<\n", 198 | "Right shift >>\n" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "id": "1a2a459e", 205 | "metadata": {}, 206 | "outputs": [], 207 | "source": [] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "id": "9a9ad437", 212 | "metadata": {}, 213 | "source": [ 214 | "# -------------------------------------Page End-------------------------------------\n", 215 | "Asterisc.in \n", 216 | "We will help you bring out the best in you...!! \n", 217 | "Industrial Training / Internship / College Projects\n", 218 | "Contact 7744822228 / 7743822228 \n", 219 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 220 | ] 221 | } 222 | ], 223 | "metadata": { 224 | "kernelspec": { 225 | "display_name": "Python 3 (ipykernel)", 226 | "language": "python", 227 | "name": "python3" 228 | }, 229 | "language_info": { 230 | "codemirror_mode": { 231 | "name": "ipython", 232 | "version": 3 233 | }, 234 | "file_extension": ".py", 235 | "mimetype": "text/x-python", 236 | "name": "python", 237 | "nbconvert_exporter": "python", 238 | "pygments_lexer": "ipython3", 239 | "version": "3.9.7" 240 | } 241 | }, 242 | "nbformat": 4, 243 | "nbformat_minor": 5 244 | } 245 | -------------------------------------------------------------------------------- /Day 11/day11.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "7e784e54", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "ram\n", 14 | "sham\n", 15 | "geeta\n" 16 | ] 17 | } 18 | ], 19 | "source": [ 20 | "a=[\"ram\",\"sham\",\"geeta\"]\n", 21 | "for i in a:\n", 22 | " print(i)" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 2, 28 | "id": "5a7a9bda", 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "name": "stdout", 33 | "output_type": "stream", 34 | "text": [ 35 | "hello geeta\n" 36 | ] 37 | } 38 | ], 39 | "source": [ 40 | "for i in a:\n", 41 | " if \"geeta\"== i:\n", 42 | " print(\"hello \",i)" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 3, 48 | "id": "8f54475f", 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "hello ram\n", 56 | "hello sham\n", 57 | "hello geeta\n", 58 | "hello om\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "a=[\"ram\",\"sham\",\"geeta\",\"om\",\"pooja\",\"yash\"]\n", 64 | "\n", 65 | "for i in a:\n", 66 | " print(\"hello \",i)\n", 67 | " if \"om\"== i:\n", 68 | " break;" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 5, 74 | "id": "148be6d4", 75 | "metadata": {}, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "hello ram\n", 82 | "hello sham\n", 83 | "hello geeta\n", 84 | "hello pooja\n", 85 | "hello yash\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "a=[\"ram\",\"sham\",\"geeta\",\"om\",\"pooja\",\"yash\"]\n", 91 | "\n", 92 | "for i in a:\n", 93 | " if \"om\"== i:\n", 94 | " continue;\n", 95 | " \n", 96 | " print(\"hello \",i)\n", 97 | " " 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 6, 103 | "id": "3366b392", 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "range(0, 7)\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "print(range(7))" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 12, 121 | "id": "be3a65dd", 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "name": "stdout", 126 | "output_type": "stream", 127 | "text": [ 128 | "1\n", 129 | "4\n", 130 | "7\n", 131 | "10\n", 132 | "13\n", 133 | "16\n", 134 | "19\n", 135 | "22\n", 136 | "25\n", 137 | "28\n", 138 | "31\n", 139 | "34\n", 140 | "37\n", 141 | "40\n", 142 | "43\n", 143 | "46\n", 144 | "49\n", 145 | "loop end\n" 146 | ] 147 | } 148 | ], 149 | "source": [ 150 | "for i in range(1,50,3): \n", 151 | " print(i)\n", 152 | "else:\n", 153 | " print(\"loop end\")" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 13, 159 | "id": "7cfc21b6", 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "0 0\n", 167 | "0 1\n", 168 | "0 2\n", 169 | "1 0\n", 170 | "1 1\n", 171 | "1 2\n", 172 | "2 0\n", 173 | "2 1\n", 174 | "2 2\n", 175 | "3 0\n", 176 | "3 1\n", 177 | "3 2\n", 178 | "4 0\n", 179 | "4 1\n", 180 | "4 2\n" 181 | ] 182 | } 183 | ], 184 | "source": [ 185 | "for i in range(5):\n", 186 | " for j in range(3):\n", 187 | " print(i,\" \",j)\n", 188 | " " 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 24, 194 | "id": "854e7763", 195 | "metadata": {}, 196 | "outputs": [ 197 | { 198 | "name": "stdout", 199 | "output_type": "stream", 200 | "text": [ 201 | "0 0\n", 202 | "0 1\n", 203 | "0 2\n", 204 | "1 0\n", 205 | "1 1\n", 206 | "1 2\n", 207 | "2 0\n", 208 | "2 1\n", 209 | "2 2\n", 210 | "4 0\n", 211 | "4 1\n", 212 | "4 2\n" 213 | ] 214 | } 215 | ], 216 | "source": [ 217 | "for i in range(5):\n", 218 | " if 3==i:\n", 219 | " continue\n", 220 | " for j in range(3):\n", 221 | " print(i,\"\",j)" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "id": "6a6ecda8", 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "id": "c67dd41e", 236 | "metadata": {}, 237 | "outputs": [], 238 | "source": [] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": null, 243 | "id": "a20b2081", 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": null, 251 | "id": "78d2d5f6", 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [] 255 | } 256 | ], 257 | "metadata": { 258 | "kernelspec": { 259 | "display_name": "Python 3 (ipykernel)", 260 | "language": "python", 261 | "name": "python3" 262 | }, 263 | "language_info": { 264 | "codemirror_mode": { 265 | "name": "ipython", 266 | "version": 3 267 | }, 268 | "file_extension": ".py", 269 | "mimetype": "text/x-python", 270 | "name": "python", 271 | "nbconvert_exporter": "python", 272 | "pygments_lexer": "ipython3", 273 | "version": "3.10.3" 274 | } 275 | }, 276 | "nbformat": 4, 277 | "nbformat_minor": 5 278 | } 279 | -------------------------------------------------------------------------------- /Day 04/Notebook4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "e624ed92", 6 | "metadata": {}, 7 | "source": [ 8 | "# Strings\n", 9 | "\n", 10 | "Strings in python are surrounded by either single quotation marks, or double quotation marks.\n", 11 | "'hello' is the same as \"hello\"\n" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "id": "01a1b906", 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "id": "e0fe9a1f", 25 | "metadata": {}, 26 | "source": [ 27 | "# String Concatenation\n", 28 | "\n", 29 | "To concatenate, or combine, two strings you can use the + operator.\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "id": "876f615f", 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "id": "dc4445f9", 43 | "metadata": {}, 44 | "source": [ 45 | "# Multiline Strings\n", 46 | "\n", 47 | "Three single quotes:\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "id": "18dbea61", 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "id": "116d8196", 61 | "metadata": {}, 62 | "source": [ 63 | "# String Length\n", 64 | "\n", 65 | "len()\n" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "id": "b17271fc", 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "id": "62d58ea0", 79 | "metadata": {}, 80 | "source": [ 81 | "# Check String\n", 82 | "\n", 83 | "we can use the keyword -> in" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "id": "986b0d23", 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "id": "1e7db2ab", 97 | "metadata": {}, 98 | "source": [ 99 | "# Slicing\n", 100 | "\n", 101 | "You can return a range of characters by using the slice syntax.\n", 102 | "\n", 103 | "[start index : end index]\n", 104 | "\n" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "id": "0c8b710c", 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "id": "ddc60d64", 118 | "metadata": {}, 119 | "source": [ 120 | "# Slice From the Start\n", 121 | "\n", 122 | "[ : end index]" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "id": "48b5fd0f", 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "id": "0e74f64b", 136 | "metadata": {}, 137 | "source": [ 138 | "# Slice To the End\n", 139 | "\n", 140 | "[start index : ]" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "id": "ca130f1b", 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "id": "6239d358", 154 | "metadata": {}, 155 | "source": [ 156 | "# Negative Indexing\n", 157 | "\n", 158 | "[ -start index : -end index]" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "id": "a66c184e", 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "id": "e9a3da10", 172 | "metadata": {}, 173 | "source": [ 174 | "# Modify Strings\n", 175 | "\n", 176 | "Python has a set of built-in methods that you can use on strings." 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "id": "0d6bab05", 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "id": "ba44ca1d", 191 | "metadata": {}, 192 | "outputs": [], 193 | "source": [ 194 | "upper() method" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": null, 200 | "id": "abd63d7d", 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": null, 208 | "id": "23c58fd9", 209 | "metadata": {}, 210 | "outputs": [], 211 | "source": [ 212 | "lower() method" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": null, 218 | "id": "eb7fe687", 219 | "metadata": {}, 220 | "outputs": [], 221 | "source": [] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": null, 226 | "id": "1180824f", 227 | "metadata": {}, 228 | "outputs": [], 229 | "source": [ 230 | "strip() method Remove Whitespace" 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": null, 236 | "id": "e6fbb542", 237 | "metadata": {}, 238 | "outputs": [], 239 | "source": [] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": null, 244 | "id": "83ea649d", 245 | "metadata": {}, 246 | "outputs": [], 247 | "source": [ 248 | "replace() method" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": null, 254 | "id": "bf7acc67", 255 | "metadata": {}, 256 | "outputs": [], 257 | "source": [] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "id": "c6933e3e", 263 | "metadata": {}, 264 | "outputs": [], 265 | "source": [ 266 | "split() method" 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": null, 272 | "id": "31a7da83", 273 | "metadata": {}, 274 | "outputs": [], 275 | "source": [] 276 | }, 277 | { 278 | "cell_type": "markdown", 279 | "id": "45acecd7", 280 | "metadata": {}, 281 | "source": [ 282 | "# String Format\n", 283 | "\n", 284 | "format() method and placeholders {}" 285 | ] 286 | }, 287 | { 288 | "cell_type": "code", 289 | "execution_count": null, 290 | "id": "61ebde34", 291 | "metadata": {}, 292 | "outputs": [], 293 | "source": [] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": null, 298 | "id": "8fa76f34", 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [] 302 | } 303 | ], 304 | "metadata": { 305 | "kernelspec": { 306 | "display_name": "Python 3 (ipykernel)", 307 | "language": "python", 308 | "name": "python3" 309 | }, 310 | "language_info": { 311 | "codemirror_mode": { 312 | "name": "ipython", 313 | "version": 3 314 | }, 315 | "file_extension": ".py", 316 | "mimetype": "text/x-python", 317 | "name": "python", 318 | "nbconvert_exporter": "python", 319 | "pygments_lexer": "ipython3", 320 | "version": "3.9.7" 321 | } 322 | }, 323 | "nbformat": 4, 324 | "nbformat_minor": 5 325 | } 326 | -------------------------------------------------------------------------------- /Day 02/Day 2 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "e6a996e5", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Data Types\n", 9 | "\n", 10 | "Built-in Data Types\n", 11 | "In programming, data type is an important concept.\n", 12 | "\n", 13 | "Variables can store data of different types, and different types can do different things.\n", 14 | "\n", 15 | "Python has the following data types built-in by default\n", 16 | "\n", 17 | " Text Type:\tstr\n", 18 | "\n", 19 | " Numeric Types :\tint, float, complex\n", 20 | "\n", 21 | " Sequence Types :\tlist, tuple, range\n", 22 | "\n", 23 | " Mapping Type :\tdict\n", 24 | "\n", 25 | " Set Types :\tset\n", 26 | "\n", 27 | " Boolean Type :\tbool\n", 28 | "\n", 29 | " Binary Types :\tbytes\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "id": "9aac16f1", 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "id": "15557787", 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "id": "16094543", 51 | "metadata": {}, 52 | "source": [ 53 | "# Python Operators\n", 54 | "\n", 55 | "An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation\n", 56 | "\n", 57 | "#following groups:\n", 58 | "\n", 59 | "1. Arithmetic operators\n", 60 | "2. Assignment operators\n", 61 | "3. Comparison operators\n", 62 | "4. Logical operators\n", 63 | "5. Identity operators\n", 64 | "6. Membership operators\n", 65 | "7. Bitwise operators" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "id": "93235cca", 71 | "metadata": {}, 72 | "source": [ 73 | "# 1. Arithmetic operators\n", 74 | "Arithmetic operators are used with numeric values to perform common mathematical operations:" 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "id": "dd946842", 80 | "metadata": {}, 81 | "source": [ 82 | "Addition + \n", 83 | "Subtraction - \n", 84 | "Multiplication *\n", 85 | "Division /\n", 86 | "Modulus %\n", 87 | "Exponentiation **\n", 88 | "\n", 89 | "Floor division // [ the floor division // rounds the result down to the nearest whole number ]" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "id": "bbc5696a", 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "x=15\n", 100 | "y=2" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": null, 106 | "id": "dc947c24", 107 | "metadata": {}, 108 | "outputs": [], 109 | "source": [] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "f6474c24", 114 | "metadata": {}, 115 | "source": [ 116 | "# Python Assignment Operators\n", 117 | "\n", 118 | "= += -= *= /= %= //= **= " 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "id": "7456f8c4", 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "id": "1bc45c9d", 132 | "metadata": {}, 133 | "source": [ 134 | "# Python Comparison Operators\n", 135 | "\n", 136 | "== != > < >= <=" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "id": "85dc56a0", 143 | "metadata": {}, 144 | "outputs": [], 145 | "source": [] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "id": "74bb7cdc", 150 | "metadata": {}, 151 | "source": [ 152 | "# Python Logical Operators\n", 153 | "\n", 154 | "and | or | not" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": null, 160 | "id": "8fec4cf6", 161 | "metadata": {}, 162 | "outputs": [], 163 | "source": [] 164 | }, 165 | { 166 | "cell_type": "markdown", 167 | "id": "1fc54253", 168 | "metadata": {}, 169 | "source": [ 170 | "# Python Identity Operators\n", 171 | "\n", 172 | "used to compare the objects\n", 173 | "\n", 174 | "is | is not " 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 1, 180 | "id": "42c9e38d", 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "x = []\n", 185 | "y = []\n", 186 | "z = x" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 3, 192 | "id": "dfd936f1", 193 | "metadata": {}, 194 | "outputs": [ 195 | { 196 | "data": { 197 | "text/plain": [ 198 | "True" 199 | ] 200 | }, 201 | "execution_count": 3, 202 | "metadata": {}, 203 | "output_type": "execute_result" 204 | } 205 | ], 206 | "source": [] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "id": "50a1611b", 211 | "metadata": {}, 212 | "source": [ 213 | "# Python Membership Operators\n", 214 | "\n", 215 | "used to test if a sequence is presented in an object:\n", 216 | "\n", 217 | "in | not in" 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": null, 223 | "id": "c8477be2", 224 | "metadata": {}, 225 | "outputs": [], 226 | "source": [] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "id": "65e540e7", 231 | "metadata": {}, 232 | "source": [ 233 | "# Python Bitwise Operators\n", 234 | "\n", 235 | "Bitwise operators are used to compare (binary) numbers:\n", 236 | "\n", 237 | "AND & \n", 238 | "OR | \n", 239 | "XOR ^ \n", 240 | "NOT ~ \n", 241 | "Left shift <<\n", 242 | "Right shift >>\n" 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": null, 248 | "id": "1a2a459e", 249 | "metadata": {}, 250 | "outputs": [], 251 | "source": [] 252 | }, 253 | { 254 | "cell_type": "markdown", 255 | "id": "9a9ad437", 256 | "metadata": {}, 257 | "source": [ 258 | "# -------------------------------------Page End-------------------------------------\n", 259 | "Asterisc.in \n", 260 | "We will help you bring out the best in you...!! \n", 261 | "Industrial Training / Internship / College Projects\n", 262 | "Contact 7744822228 / 7743822228 \n", 263 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 264 | ] 265 | } 266 | ], 267 | "metadata": { 268 | "kernelspec": { 269 | "display_name": "Python 3 (ipykernel)", 270 | "language": "python", 271 | "name": "python3" 272 | }, 273 | "language_info": { 274 | "codemirror_mode": { 275 | "name": "ipython", 276 | "version": 3 277 | }, 278 | "file_extension": ".py", 279 | "mimetype": "text/x-python", 280 | "name": "python", 281 | "nbconvert_exporter": "python", 282 | "pygments_lexer": "ipython3", 283 | "version": "3.9.7" 284 | } 285 | }, 286 | "nbformat": 4, 287 | "nbformat_minor": 5 288 | } 289 | -------------------------------------------------------------------------------- /Day 05/Notebook5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "48e2f4f2", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Lists\n", 9 | "\n", 10 | "Lists are used to store multiple items in a single variable.\n", 11 | "\n", 12 | "1> Ordered\n", 13 | "2> Mutable\n", 14 | "3> [] or list()\n", 15 | "4> Allow Duplicate" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "id": "578206a9", 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "id": "9d7ab3b1", 29 | "metadata": {}, 30 | "source": [ 31 | "# Access Items\n", 32 | "\n", 33 | "Indexing [1]\n", 34 | "Negative Indexing [-1]\n", 35 | "\n", 36 | "# Slicing\n", 37 | "\n", 38 | "Range of Indexes [2:5]\n", 39 | "Range of Negative Indexes[-4:-1]\n", 40 | "\n", 41 | "# Check\n", 42 | "\n", 43 | "Check if Item Exists --> in" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "id": "a04a5582", 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "6a548f8c", 57 | "metadata": {}, 58 | "source": [ 59 | "# List Methods" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "id": "1507fd1f", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "len(iterable) # many items a list has" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "id": "1ae22eef", 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "id": "894195b1", 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "append(element) # Adds an element at the end of the list" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": null, 93 | "id": "c2dfe407", 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "id": "ca8eff82", 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "clear() # Removes all the elements from the list" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "id": "a3ec8298", 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "id": "c3fff132", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "copy() # Returns a copy of the list" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "id": "3f677548", 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "id": "17c982d3", 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "count(value) # Returns the number of elements with the specified value" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "id": "73b59d7d", 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "id": "616e5104", 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "extend(iterable) # Add the elements of a list to the end of the current list" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "id": "64c62fd4", 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "id": "ba980f6c", 174 | "metadata": {}, 175 | "outputs": [], 176 | "source": [ 177 | "index(element) # Returns the index of the first element with the specified value" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "id": "f7186223", 184 | "metadata": {}, 185 | "outputs": [], 186 | "source": [] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": null, 191 | "id": "23abadf9", 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "insert(position, element) # Adds an element at the specified position" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "id": "bb542a7f", 202 | "metadata": {}, 203 | "outputs": [], 204 | "source": [] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": null, 209 | "id": "b7e22557", 210 | "metadata": {}, 211 | "outputs": [], 212 | "source": [ 213 | "pop(position) # Removes the element at the specified position" 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": null, 219 | "id": "8c1016e3", 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "id": "1e6fc98c", 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [ 231 | "remove(element) # Removes the item with the specified value" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "id": "2765d6a6", 238 | "metadata": {}, 239 | "outputs": [], 240 | "source": [] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": null, 245 | "id": "17400d2c", 246 | "metadata": {}, 247 | "outputs": [], 248 | "source": [ 249 | "reverse() # Reverses the order of the list" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "id": "1716b82c", 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": null, 263 | "id": "32d81246", 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [ 267 | "sort() # Sorts the list" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": null, 273 | "id": "bc07ac25", 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [] 277 | }, 278 | { 279 | "cell_type": "markdown", 280 | "id": "9a9ad437", 281 | "metadata": {}, 282 | "source": [ 283 | "# -------------------------------------Page End-------------------------------------\n", 284 | "Asterisc.in \n", 285 | "We will help you bring out the best in you...!! \n", 286 | "Industrial Training / Internship / College Projects\n", 287 | "Contact 7744822228 / 7743822228 \n", 288 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 289 | ] 290 | } 291 | ], 292 | "metadata": { 293 | "kernelspec": { 294 | "display_name": "Python 3 (ipykernel)", 295 | "language": "python", 296 | "name": "python3" 297 | }, 298 | "language_info": { 299 | "codemirror_mode": { 300 | "name": "ipython", 301 | "version": 3 302 | }, 303 | "file_extension": ".py", 304 | "mimetype": "text/x-python", 305 | "name": "python", 306 | "nbconvert_exporter": "python", 307 | "pygments_lexer": "ipython3", 308 | "version": "3.10.3" 309 | } 310 | }, 311 | "nbformat": 4, 312 | "nbformat_minor": 5 313 | } 314 | -------------------------------------------------------------------------------- /Day 09/Day 9 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "2d6c7169", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Condition statements" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "8427b0c7", 14 | "metadata": {}, 15 | "source": [ 16 | "# Python If ... Else" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "id": "19dace06", 22 | "metadata": {}, 23 | "source": [ 24 | "Python Conditions and If statements" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 3, 30 | "id": "e0b12746", 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "ename": "IndentationError", 35 | "evalue": "unexpected indent (3939460655.py, line 9)", 36 | "output_type": "error", 37 | "traceback": [ 38 | "\u001b[1;36m Input \u001b[1;32mIn [3]\u001b[1;36m\u001b[0m\n\u001b[1;33m print(\"hi\")\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m unexpected indent\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "age =int(input(\"Enter your age\"))\n", 44 | "\n", 45 | "if age>18 :\n", 46 | " print(\"hello\")\n", 47 | " print(\"hey\")\n", 48 | "\n", 49 | "if age<18:\n", 50 | " print(\"bye\")\n", 51 | " print(\"hi\") \n", 52 | "\n", 53 | "print(\"hi2\") \n", 54 | "\n", 55 | "#10" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "id": "bea509c4", 61 | "metadata": {}, 62 | "source": [ 63 | "# if" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "id": "21d3d00c", 70 | "metadata": {}, 71 | "outputs": [], 72 | "source": [] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "id": "b87357a1", 77 | "metadata": {}, 78 | "source": [ 79 | "# else" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 1, 85 | "id": "af778f94", 86 | "metadata": {}, 87 | "outputs": [ 88 | { 89 | "name": "stdout", 90 | "output_type": "stream", 91 | "text": [ 92 | "Enter your age29\n", 93 | "valid\n", 94 | "hi\n" 95 | ] 96 | } 97 | ], 98 | "source": [ 99 | "age =int(input(\"Enter your age\"))\n", 100 | "if age>18:\n", 101 | " print(\"valid\")\n", 102 | " print(\"hi\")\n", 103 | "else:\n", 104 | " print(\"not valid\")\n", 105 | " \n", 106 | "#29\n", 107 | "#18\n", 108 | "#10" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "70086dd2", 114 | "metadata": {}, 115 | "source": [ 116 | "# elif" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 6, 122 | "id": "f76290f2", 123 | "metadata": {}, 124 | "outputs": [ 125 | { 126 | "name": "stdout", 127 | "output_type": "stream", 128 | "text": [ 129 | "Enter your f no1\n", 130 | "x1st floor\n" 131 | ] 132 | } 133 | ], 134 | "source": [ 135 | "f=int(input(\"Enter your f no\")) #3\n", 136 | "\n", 137 | "if f==1:\n", 138 | " print(\"x1st floor\")\n", 139 | " print(\"y1st floor\")\n", 140 | "elif f==2:\n", 141 | " print(\"2st floor\")\n", 142 | "elif f==3:\n", 143 | " print(\"3st floor\")\n", 144 | "elif f==4:\n", 145 | " print(\"4st floor\")\n", 146 | "else:\n", 147 | " print(\"badiya aapn he rakh lete hai\")" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "id": "c774b1a4", 153 | "metadata": {}, 154 | "source": [ 155 | "# Short Hand If" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": 7, 161 | "id": "a7b31d8b", 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "name": "stdout", 166 | "output_type": "stream", 167 | "text": [ 168 | "Enter your age29\n", 169 | "valid\n" 170 | ] 171 | } 172 | ], 173 | "source": [ 174 | "age =int(input(\"Enter your age\"))\n", 175 | "if age>18: print(\"valid\")" 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "id": "f37d78c6", 181 | "metadata": {}, 182 | "source": [ 183 | "# Short Hand If ... Else" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": 10, 189 | "id": "330f57fc", 190 | "metadata": {}, 191 | "outputs": [ 192 | { 193 | "name": "stdout", 194 | "output_type": "stream", 195 | "text": [ 196 | "Enter your age10\n", 197 | "not valid\n" 198 | ] 199 | } 200 | ], 201 | "source": [ 202 | "age =int(input(\"Enter your age\"))\n", 203 | "\n", 204 | "\n", 205 | "print(\"valid\") if age>18 else print(\"not valid\")\n" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "id": "3734b08d", 211 | "metadata": {}, 212 | "source": [ 213 | "# logical operator -> and , or " 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": 14, 219 | "id": "f257632a", 220 | "metadata": {}, 221 | "outputs": [ 222 | { 223 | "name": "stdout", 224 | "output_type": "stream", 225 | "text": [ 226 | "Enter your age35\n", 227 | "not valid\n" 228 | ] 229 | } 230 | ], 231 | "source": [ 232 | "age =int(input(\"Enter your age\"))\n", 233 | "\n", 234 | "if age >18 and age<30:\n", 235 | " print(\"valid\")\n", 236 | "else:\n", 237 | " print(\"not valid\")" 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "id": "40d670b1", 243 | "metadata": {}, 244 | "source": [ 245 | "# Nested If" 246 | ] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": 18, 251 | "id": "8ce3da53", 252 | "metadata": {}, 253 | "outputs": [ 254 | { 255 | "name": "stdout", 256 | "output_type": "stream", 257 | "text": [ 258 | "Enter number 120\n", 259 | "Enter number 220\n", 260 | "Enter number 310\n", 261 | "B is bigger number\n" 262 | ] 263 | } 264 | ], 265 | "source": [ 266 | "a =int(input(\"Enter number 1\"))\n", 267 | "b =int(input(\"Enter number 2\"))\n", 268 | "c =int(input(\"Enter number 3\"))\n", 269 | "\n", 270 | "if a>b :\n", 271 | " if a>c:\n", 272 | " print(\"A is bigger number\")\n", 273 | " else:\n", 274 | " print(\"C is bigger number\")\n", 275 | "else:\n", 276 | " if b>c:\n", 277 | " print(\"B is bigger number\")\n", 278 | " else:\n", 279 | " print(\"C is bigger number\")\n" 280 | ] 281 | }, 282 | { 283 | "cell_type": "markdown", 284 | "id": "5e04f2cd", 285 | "metadata": {}, 286 | "source": [ 287 | "# -------------------------------------Page End-------------------------------------\n", 288 | "Asterisc.in \n", 289 | "We will help you bring out the best in you...!! \n", 290 | "Industrial Training / Internship / College Projects\n", 291 | "Contact 7744822228 / 7743822228 \n", 292 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": null, 298 | "id": "eb1d13fa", 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [] 302 | } 303 | ], 304 | "metadata": { 305 | "kernelspec": { 306 | "display_name": "Python 3 (ipykernel)", 307 | "language": "python", 308 | "name": "python3" 309 | }, 310 | "language_info": { 311 | "codemirror_mode": { 312 | "name": "ipython", 313 | "version": 3 314 | }, 315 | "file_extension": ".py", 316 | "mimetype": "text/x-python", 317 | "name": "python", 318 | "nbconvert_exporter": "python", 319 | "pygments_lexer": "ipython3", 320 | "version": "3.10.3" 321 | } 322 | }, 323 | "nbformat": 4, 324 | "nbformat_minor": 5 325 | } 326 | -------------------------------------------------------------------------------- /Day 08/NoteBook8.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "afcc28c2", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Dictionary\n", 9 | "\n", 10 | "Dictionaries are used to store data values in key:value pairs.\n", 11 | "\n", 12 | "1> ordered* (Version 3.7, dictionaries are ordered. Version 3.6 and earlier, dictionaries are unordered.)\n", 13 | "2> mutable / changeable (Once a set is created, you cannot change its items, but you can remove items and add new items)\n", 14 | "3> { } or dict()\n", 15 | "4> Not Allow Duplicate Key\n", 16 | "5> unindexed" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 18, 22 | "id": "ab5c8d6c", 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "name": "stdout", 27 | "output_type": "stream", 28 | "text": [ 29 | "False\n" 30 | ] 31 | } 32 | ], 33 | "source": [ 34 | "x={\"name\":\"ram\",\"address\":\"nagpur\",\"mob\":8087737679}\n", 35 | "\n", 36 | "print(\"8087737673\" in x)" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "id": "e76a2ea2", 42 | "metadata": {}, 43 | "source": [ 44 | "# Access Items\n", 45 | "\n", 46 | "Indexing dict[\"key\"]\n", 47 | "dict.get(\"key\") return value\n", 48 | "\n", 49 | "list of the keys:\n", 50 | "dict.keys()\n", 51 | "\n", 52 | "list of the values:\n", 53 | "dict.values()\n", 54 | "\n", 55 | "list of the key:value pairs\n", 56 | "dict.items()\n", 57 | "\n", 58 | "Check\n", 59 | "Check if Item Exists --> in" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "id": "2ac83562", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "id": "9e23b40e", 73 | "metadata": {}, 74 | "source": [ 75 | "# Change Dictionary Items\n", 76 | "\n", 77 | "dict[\"key\"]=\"value\"\n", 78 | "dict.update({\"key\": value})" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "id": "37bfaac1", 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "id": "d9f58acc", 92 | "metadata": {}, 93 | "source": [ 94 | "# Add new Item in Dictionary\n", 95 | "\n", 96 | "dict[\"new key\"] = \"value\"\n", 97 | "dict.update({\"new key\": \"value\"})" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "id": "64a78869", 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "id": "c7b5b202", 111 | "metadata": {}, 112 | "source": [ 113 | "# Dictionary Method" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "id": "dccacc0d", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | "dict.clear() # Removes all the elements from the dictionary" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "id": "3e52a540", 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "id": "d88f24ff", 138 | "metadata": {}, 139 | "outputs": [], 140 | "source": [ 141 | "dict.copy() # Returns a copy of the dictionary" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "id": "d23ecc90", 148 | "metadata": {}, 149 | "outputs": [], 150 | "source": [] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "id": "87faff45", 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "dict.fromkeys(keys) # Returns a dictionary with the specified keys and value is none" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": 19, 165 | "id": "dba3c0ef", 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [ 169 | "x={1,2,3,4}\n", 170 | "z=dict.fromkeys(x)" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": 26, 176 | "id": "7ca019d0", 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": null, 184 | "id": "69b53306", 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "dict.pop(keyname, defaultvalue) # Removes the element with the specified key" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "id": "b141d158", 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": null, 202 | "id": "15dc4933", 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "dict.popitem() # Removes the last inserted key-value pair" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "id": "c032f67e", 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": null, 220 | "id": "9afa9494", 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [ 224 | "dict.setdefault(keyname, value) \n", 225 | "#Returns the value of the specified key. If the key does not exist: insert the key, with the specified value" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": null, 231 | "id": "89797783", 232 | "metadata": {}, 233 | "outputs": [], 234 | "source": [] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": null, 239 | "id": "3b20d139", 240 | "metadata": {}, 241 | "outputs": [], 242 | "source": [] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": null, 247 | "id": "07b8c905", 248 | "metadata": {}, 249 | "outputs": [], 250 | "source": [] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "id": "502938ac", 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "id": "61e0051b", 263 | "metadata": {}, 264 | "source": [ 265 | "# Boolean Values\n", 266 | "\n", 267 | "Booleans represent one of two values: True or False." 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": null, 273 | "id": "44ecb656", 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "print(10 > 9)\n", 278 | "print(10 == 9)\n", 279 | "print(10 < 9)" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": null, 285 | "id": "196ccd1f", 286 | "metadata": {}, 287 | "outputs": [], 288 | "source": [ 289 | "print(bool(\"Hello\"))\n", 290 | "print(bool(15))" 291 | ] 292 | }, 293 | { 294 | "cell_type": "code", 295 | "execution_count": null, 296 | "id": "dc492466", 297 | "metadata": {}, 298 | "outputs": [], 299 | "source": [ 300 | "bool(False)\n", 301 | "bool(None)\n", 302 | "bool(0)\n", 303 | "bool(\"\")\n", 304 | "bool(())\n", 305 | "bool([])\n", 306 | "bool({})" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "id": "5e04f2cd", 312 | "metadata": {}, 313 | "source": [ 314 | "# -------------------------------------Page End-------------------------------------\n", 315 | "Asterisc.in \n", 316 | "We will help you bring out the best in you...!! \n", 317 | "Industrial Training / Internship / College Projects\n", 318 | "Contact 7744822228 / 7743822228 \n", 319 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 320 | ] 321 | } 322 | ], 323 | "metadata": { 324 | "kernelspec": { 325 | "display_name": "Python 3 (ipykernel)", 326 | "language": "python", 327 | "name": "python3" 328 | }, 329 | "language_info": { 330 | "codemirror_mode": { 331 | "name": "ipython", 332 | "version": 3 333 | }, 334 | "file_extension": ".py", 335 | "mimetype": "text/x-python", 336 | "name": "python", 337 | "nbconvert_exporter": "python", 338 | "pygments_lexer": "ipython3", 339 | "version": "3.9.7" 340 | } 341 | }, 342 | "nbformat": 4, 343 | "nbformat_minor": 5 344 | } 345 | -------------------------------------------------------------------------------- /Day 12/NoteBook12.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "3922983d", 6 | "metadata": {}, 7 | "source": [ 8 | "# FUNCTION" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "6855ae78", 14 | "metadata": {}, 15 | "source": [ 16 | "# no return no argument" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 4, 22 | "id": "8ae968ee", 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "name": "stdout", 27 | "output_type": "stream", 28 | "text": [ 29 | "Enter a: 4\n", 30 | "Enter b: 5\n", 31 | "Addition= 9\n", 32 | "Enter a: 7\n", 33 | "Enter b: 8\n", 34 | "Addition= 15\n", 35 | "Enter two values: 7 8\n", 36 | "First Number: 7\n", 37 | "Second Number: 8\n", 38 | "result 15\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "def myfun():\n", 44 | " a = int(input(\"Enter a: \")) \n", 45 | " b = int(input(\"Enter b: \"))\n", 46 | " #a,b = input(\"Enter two values: \").split(\",\")\n", 47 | " print(\"Addition=\",a+b)\n", 48 | "\n", 49 | "def fun():\n", 50 | " x, y = input(\"Enter two values: \").split()#.split()\n", 51 | " print(\"First Number: \", x)\n", 52 | " print(\"Second Number: \", y)\n", 53 | " z=int(x)+int(y)\n", 54 | " print(\"result \",z)\n", 55 | "\n", 56 | " \n", 57 | "myfun()\n", 58 | "myfun()\n", 59 | "fun()" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "id": "d40709f1", 65 | "metadata": {}, 66 | "source": [ 67 | "# return but no argument" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 6, 73 | "id": "3e289562", 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "Enter a: 12\n", 81 | "Enter b: 3\n", 82 | "Subtraction= 9\n" 83 | ] 84 | } 85 | ], 86 | "source": [ 87 | "def sub(): \n", 88 | " a = int(input(\"Enter a: \")) \n", 89 | " b = int(input(\"Enter b: \")) \n", 90 | " c = a-b \n", 91 | " return c\n", 92 | "j=sub()\n", 93 | "print(\"Subtraction=\",j)" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "id": "9030c54c", 99 | "metadata": {}, 100 | "source": [ 101 | "# no return but argument\n" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 7, 107 | "id": "ee0713b2", 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "pooja sao\n", 115 | "SQUARE= 4\n" 116 | ] 117 | } 118 | ], 119 | "source": [ 120 | "def my_function(fname, lname):\n", 121 | " print(fname + \" \" + lname)\n", 122 | "\n", 123 | "def square(a):\n", 124 | " print(\"SQUARE=\",a*a)\n", 125 | "\n", 126 | "my_function(\"pooja\",\"sao\")\n", 127 | "square(2)" 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "id": "1d45ffd3", 133 | "metadata": {}, 134 | "source": [ 135 | "# return with argument" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 25, 141 | "id": "d513c8e3", 142 | "metadata": {}, 143 | "outputs": [ 144 | { 145 | "name": "stdout", 146 | "output_type": "stream", 147 | "text": [ 148 | "odd\n", 149 | "5\n" 150 | ] 151 | } 152 | ], 153 | "source": [ 154 | "def myFunRetn(a):\n", 155 | " if(a%2==0):\n", 156 | " print(\"Even number is:\")\n", 157 | " return a\n", 158 | " else:\n", 159 | " print(\"odd\")\n", 160 | " return a\n", 161 | "a=myFunRetn(5)\n", 162 | "print(a)" 163 | ] 164 | }, 165 | { 166 | "cell_type": "markdown", 167 | "id": "e985b977", 168 | "metadata": {}, 169 | "source": [ 170 | "# Arbitrary Arguments, *args (Non- Keyword Arguments)" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "id": "649e8243", 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [ 180 | "# If you do not know how many arguments that will be passed into your function, add a * before the parameter name in the function definition.\n", 181 | "\n", 182 | "# function will receive a tuple of arguments, and can access the items accordingly index bases:" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": 9, 188 | "id": "372c5bd3", 189 | "metadata": {}, 190 | "outputs": [ 191 | { 192 | "name": "stdout", 193 | "output_type": "stream", 194 | "text": [ 195 | "Mobile number is 7744822228\n", 196 | "('Asterisc', 'Nagpur', '7744822228')\n", 197 | "Asterisc\n", 198 | "Nagpur\n", 199 | "7744822228\n", 200 | "Mobile number is 7744822228\n", 201 | "('Asterisc', 'Nagpur', '7744822228', 101, 102)\n", 202 | "Asterisc\n", 203 | "Nagpur\n", 204 | "7744822228\n", 205 | "101\n", 206 | "102\n" 207 | ] 208 | } 209 | ], 210 | "source": [ 211 | "def my_function(*info):\n", 212 | " print(\"Mobile number is \" +info[2])\n", 213 | " print(info)\n", 214 | " for i in info:\n", 215 | " print(i)\n", 216 | " \n", 217 | "\n", 218 | "my_function('Asterisc', 'Nagpur', '7744822228')\n", 219 | "my_function('Asterisc', 'Nagpur', '7744822228',101,102)\n" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "id": "205d1cc1", 225 | "metadata": {}, 226 | "source": [ 227 | "# Arbitrary Keyword Arguments, **keyword args (Keyword Arguments)" 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": null, 233 | "id": "473fbbe9", 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [ 237 | "# If you do not know how many keyword arguments that will be passed into your function, add two ** before the parameter name in the function definition.\n", 238 | "\n", 239 | "# Function will receive a dictionary of arguments, and can access the items accordingly:" 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": 10, 245 | "id": "cbc61438", 246 | "metadata": {}, 247 | "outputs": [ 248 | { 249 | "name": "stdout", 250 | "output_type": "stream", 251 | "text": [ 252 | "Id is 101\n", 253 | "salary is 3000\n" 254 | ] 255 | } 256 | ], 257 | "source": [ 258 | "def my_fun(**emp):\n", 259 | " print(\"Id is \" ,emp[\"id\"])\n", 260 | " print(\"salary is \" ,emp[\"sal\"])\n", 261 | "\n", 262 | "\n", 263 | "my_fun(id = 101, sal = 3000)\n", 264 | "\n" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": 11, 270 | "id": "a2c12456", 271 | "metadata": {}, 272 | "outputs": [ 273 | { 274 | "ename": "SyntaxError", 275 | "evalue": "invalid syntax (Temp/ipykernel_2704/241222547.py, line 6)", 276 | "output_type": "error", 277 | "traceback": [ 278 | "\u001b[1;36m File \u001b[1;32m\"C:\\Users\\ast4\\AppData\\Local\\Temp/ipykernel_2704/241222547.py\"\u001b[1;36m, line \u001b[1;32m6\u001b[0m\n\u001b[1;33m myFun(id :'102', name :'geeta', sal:'3000')\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" 279 | ] 280 | } 281 | ], 282 | "source": [ 283 | "def myFun(**emp):\n", 284 | " for key, value in emp.items():\n", 285 | " print (\"%s : %s\" %(key, value))\n", 286 | " \n", 287 | "\n", 288 | "myFun(id ='102', name ='geeta', sal='3000') " 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 13, 294 | "id": "9ab811fc", 295 | "metadata": {}, 296 | "outputs": [ 297 | { 298 | "name": "stdout", 299 | "output_type": "stream", 300 | "text": [ 301 | "Value of a is= helloworld\n", 302 | "Value of a is: = hello\n" 303 | ] 304 | } 305 | ], 306 | "source": [ 307 | "def myfun(a):\n", 308 | " a+=\"world\"\n", 309 | " print(\"Value of a is=\",a)\n", 310 | "\n", 311 | "a=\"hello\"\n", 312 | "myfun(a)\n", 313 | "print(\"Value of a is: =\",a)" 314 | ] 315 | }, 316 | { 317 | "cell_type": "code", 318 | "execution_count": null, 319 | "id": "dd87e567", 320 | "metadata": {}, 321 | "outputs": [], 322 | "source": [] 323 | } 324 | ], 325 | "metadata": { 326 | "kernelspec": { 327 | "display_name": "Python 3 (ipykernel)", 328 | "language": "python", 329 | "name": "python3" 330 | }, 331 | "language_info": { 332 | "codemirror_mode": { 333 | "name": "ipython", 334 | "version": 3 335 | }, 336 | "file_extension": ".py", 337 | "mimetype": "text/x-python", 338 | "name": "python", 339 | "nbconvert_exporter": "python", 340 | "pygments_lexer": "ipython3", 341 | "version": "3.10.3" 342 | } 343 | }, 344 | "nbformat": 4, 345 | "nbformat_minor": 5 346 | } 347 | -------------------------------------------------------------------------------- /Day 06/Day 6 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "48e2f4f2", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Tuples\n", 9 | "\n", 10 | "Tuples are used to store multiple items in a single variable.\n", 11 | "\n", 12 | "1> Ordered\n", 13 | "2> immutable / Unchangeable\n", 14 | "3> () or tuple()\n", 15 | "4> Allow Duplicate" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "id": "578206a9", 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "x=(\"ram\",\"sham\",\"pooja\",\"geeta\")" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 3, 31 | "id": "9bfd690b", 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "data": { 36 | "text/plain": [ 37 | "tuple" 38 | ] 39 | }, 40 | "execution_count": 3, 41 | "metadata": {}, 42 | "output_type": "execute_result" 43 | } 44 | ], 45 | "source": [ 46 | "type(x)" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "id": "3ea6bf4a", 52 | "metadata": {}, 53 | "source": [ 54 | "# Access Items\n", 55 | "\n", 56 | "Indexing [1]\n", 57 | "Negative Indexing [-1]\n", 58 | "\n", 59 | "# Slicing\n", 60 | "\n", 61 | "Range of Indexes [2:5]\n", 62 | "Range of Negative Indexes[-4:-1]\n", 63 | "\n", 64 | "# Check\n", 65 | "\n", 66 | "Check if Item Exists --> in" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 5, 72 | "id": "75265e25", 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [ 76 | "x=(\"ram\",\"sham\",\"pooja\",\"geeta\")" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 6, 82 | "id": "df006ac2", 83 | "metadata": {}, 84 | "outputs": [ 85 | { 86 | "data": { 87 | "text/plain": [ 88 | "'geeta'" 89 | ] 90 | }, 91 | "execution_count": 6, 92 | "metadata": {}, 93 | "output_type": "execute_result" 94 | } 95 | ], 96 | "source": [ 97 | "x[-1]" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 7, 103 | "id": "5ad4783a", 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "True\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "print(\"ram\" in x)" 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "id": "4e558a14", 121 | "metadata": {}, 122 | "source": [ 123 | "# Tuples Methods" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "id": "9f78ab61", 130 | "metadata": {}, 131 | "outputs": [], 132 | "source": [ 133 | "tuple(iterable) # many items a list has" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 8, 139 | "id": "67079839", 140 | "metadata": {}, 141 | "outputs": [], 142 | "source": [ 143 | "a=[2,4,45,6,67,7,8,8]\n", 144 | "\n", 145 | "b=tuple(a)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 11, 151 | "id": "64310f95", 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "tuple" 158 | ] 159 | }, 160 | "execution_count": 11, 161 | "metadata": {}, 162 | "output_type": "execute_result" 163 | } 164 | ], 165 | "source": [ 166 | "type(b)" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "id": "7a78ea44", 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "count(value) # Returns the count of given element" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 13, 182 | "id": "682fe697", 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [ 186 | "z=b.count(8)" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 14, 192 | "id": "90dda08e", 193 | "metadata": {}, 194 | "outputs": [ 195 | { 196 | "data": { 197 | "text/plain": [ 198 | "2" 199 | ] 200 | }, 201 | "execution_count": 14, 202 | "metadata": {}, 203 | "output_type": "execute_result" 204 | } 205 | ], 206 | "source": [ 207 | "z" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "id": "b5b53ed8", 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [ 217 | "index(element) # Returns the index of the first matched item " 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": null, 223 | "id": "ceced2ee", 224 | "metadata": {}, 225 | "outputs": [], 226 | "source": [] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": null, 231 | "id": "bb373e1e", 232 | "metadata": {}, 233 | "outputs": [], 234 | "source": [ 235 | "min(tuple) # return the minimum element in tuple" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 16, 241 | "id": "e9139334", 242 | "metadata": {}, 243 | "outputs": [], 244 | "source": [ 245 | "a=(2,4,45,6,67,7,8,8)\n", 246 | "z=min(a)" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 17, 252 | "id": "6eea52fc", 253 | "metadata": {}, 254 | "outputs": [ 255 | { 256 | "data": { 257 | "text/plain": [ 258 | "2" 259 | ] 260 | }, 261 | "execution_count": 17, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "z" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": null, 273 | "id": "5f3653ad", 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "max(tuple) # return the maximum element in tuple" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "id": "bf227d3b", 284 | "metadata": {}, 285 | "outputs": [], 286 | "source": [] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": null, 291 | "id": "6555ae7a", 292 | "metadata": {}, 293 | "outputs": [], 294 | "source": [ 295 | "del(tuple) # Removes all the elements from the tuple" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": 18, 301 | "id": "d08870fb", 302 | "metadata": {}, 303 | "outputs": [], 304 | "source": [ 305 | "del(a)" 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "execution_count": 19, 311 | "id": "2f0cec0a", 312 | "metadata": {}, 313 | "outputs": [ 314 | { 315 | "ename": "NameError", 316 | "evalue": "name 'a' is not defined", 317 | "output_type": "error", 318 | "traceback": [ 319 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 320 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 321 | "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43ma\u001b[49m\n", 322 | "\u001b[1;31mNameError\u001b[0m: name 'a' is not defined" 323 | ] 324 | } 325 | ], 326 | "source": [ 327 | "a" 328 | ] 329 | }, 330 | { 331 | "cell_type": "code", 332 | "execution_count": null, 333 | "id": "01fc1e95", 334 | "metadata": {}, 335 | "outputs": [], 336 | "source": [ 337 | "sum(tuple) # Sum of numbers in the Tuple" 338 | ] 339 | }, 340 | { 341 | "cell_type": "code", 342 | "execution_count": 21, 343 | "id": "6dbfe0bf", 344 | "metadata": {}, 345 | "outputs": [], 346 | "source": [ 347 | "a=(2,4,45,6,67,7,8,8)" 348 | ] 349 | }, 350 | { 351 | "cell_type": "code", 352 | "execution_count": 22, 353 | "id": "1e560ebc", 354 | "metadata": {}, 355 | "outputs": [ 356 | { 357 | "data": { 358 | "text/plain": [ 359 | "147" 360 | ] 361 | }, 362 | "execution_count": 22, 363 | "metadata": {}, 364 | "output_type": "execute_result" 365 | } 366 | ], 367 | "source": [ 368 | "sum(a)" 369 | ] 370 | }, 371 | { 372 | "cell_type": "markdown", 373 | "id": "9a9ad437", 374 | "metadata": {}, 375 | "source": [ 376 | "# -------------------------------------Page End-------------------------------------\n", 377 | "Asterisc.in \n", 378 | "We will help you bring out the best in you...!! \n", 379 | "Industrial Training / Internship / College Projects\n", 380 | "Contact 7744822228 / 7743822228 \n", 381 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 382 | ] 383 | } 384 | ], 385 | "metadata": { 386 | "kernelspec": { 387 | "display_name": "Python 3 (ipykernel)", 388 | "language": "python", 389 | "name": "python3" 390 | }, 391 | "language_info": { 392 | "codemirror_mode": { 393 | "name": "ipython", 394 | "version": 3 395 | }, 396 | "file_extension": ".py", 397 | "mimetype": "text/x-python", 398 | "name": "python", 399 | "nbconvert_exporter": "python", 400 | "pygments_lexer": "ipython3", 401 | "version": "3.10.3" 402 | } 403 | }, 404 | "nbformat": 4, 405 | "nbformat_minor": 5 406 | } 407 | -------------------------------------------------------------------------------- /Day 07/NoteBook7.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "6643940e", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Set\n", 9 | "\n", 10 | "Set are used to store multiple items in a single variable.\n", 11 | "\n", 12 | "1> Unordered (Sets are unordered, so you cannot be sure in which order the items will appear)\n", 13 | "2> immutable / Unchangeable (Once a set is created, you cannot change its items, but you can remove items and add new items)\n", 14 | "3> {} or set()\n", 15 | "4> Not Allow Duplicate\n", 16 | "5> unindexed" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": null, 22 | "id": "cc066907", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "id": "9fd737da", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "# Check\n", 35 | "\n", 36 | "Check if Item Exists --> in" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "id": "754970f5", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "id": "faa60bc9", 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "add() #Adds an element to the set" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "id": "3be09deb", 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "id": "b42f10da", 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "clear() #Removes all the elements from the set" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": null, 78 | "id": "ad30c9b6", 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "id": "5e955ac9", 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "copy() #Returns a copy of the set" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "id": "6555a555", 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "id": "c2e7e8f0", 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "set.discard(value) # Remove the specified item" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "id": "bdd06b22", 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "id": "55090684", 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [ 126 | "set.remove(item) #Remove \"item\" from the set: error if not present" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": null, 132 | "id": "8e76f56e", 133 | "metadata": {}, 134 | "outputs": [], 135 | "source": [] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "id": "2eee1e98", 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [ 144 | "set.pop() # Remove a random item from the set and also return that item" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "id": "33c5b85a", 151 | "metadata": {}, 152 | "outputs": [], 153 | "source": [] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "id": "1fda6010", 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [ 162 | "set.difference(set,set,nset..) #Returns a set containing the difference between two or more sets" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": null, 168 | "id": "34b7540f", 169 | "metadata": {}, 170 | "outputs": [], 171 | "source": [] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "id": "6137ead9", 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [ 180 | "set.difference_update(set) # Removes the items in this set that are also included in another, specified set" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "execution_count": null, 186 | "id": "e4b5ccf7", 187 | "metadata": {}, 188 | "outputs": [], 189 | "source": [] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "id": "bb9a061f", 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [ 198 | "set.intersection(set1, set2 ... etc) # Return a set that contains the items that exist in both set x, and set y:" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "id": "5c5cc073", 205 | "metadata": {}, 206 | "outputs": [], 207 | "source": [] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "id": "fc65e1f4", 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [ 216 | "set.intersection_update(set1, set2 ... etc) # Remove the items that is not present in both x and y:" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "id": "808aafbf", 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "id": "2317b150", 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [ 234 | "set.isdisjoint(set) # Return True if no items in set x is present in set y:" 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": null, 240 | "id": "702b8a80", 241 | "metadata": {}, 242 | "outputs": [], 243 | "source": [] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": null, 248 | "id": "cd366807", 249 | "metadata": {}, 250 | "outputs": [], 251 | "source": [ 252 | "set.issubset(set) # Return True if all items in set x are present in set y:" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": null, 258 | "id": "44d81bf6", 259 | "metadata": {}, 260 | "outputs": [], 261 | "source": [] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": null, 266 | "id": "0e68dbee", 267 | "metadata": {}, 268 | "outputs": [], 269 | "source": [ 270 | "set.issuperset(set) # Return True if all items set y are present in set x:" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": null, 276 | "id": "4f781d75", 277 | "metadata": {}, 278 | "outputs": [], 279 | "source": [] 280 | }, 281 | { 282 | "cell_type": "code", 283 | "execution_count": null, 284 | "id": "44c4e99f", 285 | "metadata": {}, 286 | "outputs": [], 287 | "source": [ 288 | "set.symmetric_difference(set)\n", 289 | "# Return a set that contains all items from both sets, except items that are present in both sets:" 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "execution_count": null, 295 | "id": "46878b74", 296 | "metadata": {}, 297 | "outputs": [], 298 | "source": [] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": null, 303 | "id": "ff1e09da", 304 | "metadata": {}, 305 | "outputs": [], 306 | "source": [ 307 | "set.symmetric_difference_update(set)\n", 308 | "# Remove the items that are present in both sets, AND insert the items that is not present in both sets:" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "id": "184e30fc", 315 | "metadata": {}, 316 | "outputs": [], 317 | "source": [] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": null, 322 | "id": "37bfcea8", 323 | "metadata": {}, 324 | "outputs": [], 325 | "source": [ 326 | "set.union(set1, set2...)\n", 327 | "# Return a set that contains all items from both sets, duplicates are excluded:" 328 | ] 329 | }, 330 | { 331 | "cell_type": "code", 332 | "execution_count": null, 333 | "id": "ecee7b18", 334 | "metadata": {}, 335 | "outputs": [], 336 | "source": [] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": null, 341 | "id": "b7f358a4", 342 | "metadata": {}, 343 | "outputs": [], 344 | "source": [ 345 | "set.update(set)\n", 346 | "# Insert the items from set y into set x:" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": null, 352 | "id": "20cde9c0", 353 | "metadata": {}, 354 | "outputs": [], 355 | "source": [] 356 | }, 357 | { 358 | "cell_type": "markdown", 359 | "id": "d0a99c12", 360 | "metadata": {}, 361 | "source": [ 362 | "# -------------------------------------Page End-------------------------------------\n", 363 | "Asterisc.in \n", 364 | "We will help you bring out the best in you...!! \n", 365 | "Industrial Training / Internship / College Projects\n", 366 | "Contact 7744822228 / 7743822228 \n", 367 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 368 | ] 369 | } 370 | ], 371 | "metadata": { 372 | "kernelspec": { 373 | "display_name": "Python 3 (ipykernel)", 374 | "language": "python", 375 | "name": "python3" 376 | }, 377 | "language_info": { 378 | "codemirror_mode": { 379 | "name": "ipython", 380 | "version": 3 381 | }, 382 | "file_extension": ".py", 383 | "mimetype": "text/x-python", 384 | "name": "python", 385 | "nbconvert_exporter": "python", 386 | "pygments_lexer": "ipython3", 387 | "version": "3.9.7" 388 | } 389 | }, 390 | "nbformat": 4, 391 | "nbformat_minor": 5 392 | } 393 | -------------------------------------------------------------------------------- /Day 13/NoteBook13.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "3b461f19", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "#name\n", 11 | "#call\n", 12 | "#para\n", 13 | "#return" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 5, 19 | "id": "df46811f", 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "def myfun(a,b):\n", 24 | " return a+b\n", 25 | "\n", 26 | "x=myfun(10,2)" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 6, 32 | "id": "daddee28", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "12\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "print(x)" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "id": "19df3326", 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "Lambda function" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 7, 60 | "id": "c4304169", 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "4\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "def my(a):\n", 73 | " return a*a\n", 74 | "\n", 75 | "x=my(2)\n", 76 | "\n", 77 | "print(x)" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": 8, 83 | "id": "cf56ae72", 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "name": "stdout", 88 | "output_type": "stream", 89 | "text": [ 90 | "4\n" 91 | ] 92 | } 93 | ], 94 | "source": [ 95 | "x=lambda a :a*a\n", 96 | "\n", 97 | "print(x(2))" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "id": "d295b5cc", 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "lambda arguments : expression" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 9, 113 | "id": "b531eb35", 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "name": "stdout", 118 | "output_type": "stream", 119 | "text": [ 120 | "15\n" 121 | ] 122 | } 123 | ], 124 | "source": [ 125 | "def add(a,b,c):\n", 126 | " return a+b+c\n", 127 | "\n", 128 | "print(add(10,5,2))" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "id": "719ef326", 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "The power of lambda is better shown when you use them as an anonymous function\n", 139 | "inside another function." 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 10, 145 | "id": "d52ba55e", 146 | "metadata": {}, 147 | "outputs": [ 148 | { 149 | "name": "stdout", 150 | "output_type": "stream", 151 | "text": [ 152 | "15\n" 153 | ] 154 | } 155 | ], 156 | "source": [ 157 | "mysum =lambda a,b : a+b\n", 158 | "print(mysum(10,5))" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 13, 164 | "id": "07789ea4", 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [ 168 | "def myfun(n):\n", 169 | " return lambda a : a+n" 170 | ] 171 | }, 172 | { 173 | "cell_type": "code", 174 | "execution_count": 14, 175 | "id": "067d0c26", 176 | "metadata": {}, 177 | "outputs": [], 178 | "source": [ 179 | "mysqr=myfun(2)" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": 15, 185 | "id": "ea7621be", 186 | "metadata": {}, 187 | "outputs": [ 188 | { 189 | "name": "stdout", 190 | "output_type": "stream", 191 | "text": [ 192 | "7\n" 193 | ] 194 | } 195 | ], 196 | "source": [ 197 | "print(mysqr(5))" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 16, 203 | "id": "4cabd24d", 204 | "metadata": {}, 205 | "outputs": [], 206 | "source": [ 207 | "def bigger(a):\n", 208 | " return lambda b: a>b" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": 20, 214 | "id": "335b48f7", 215 | "metadata": {}, 216 | "outputs": [], 217 | "source": [ 218 | "res1=bigger(9)\n", 219 | "res2=bigger(3)" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": 21, 225 | "id": "1f7ac536", 226 | "metadata": {}, 227 | "outputs": [ 228 | { 229 | "name": "stdout", 230 | "output_type": "stream", 231 | "text": [ 232 | "True\n", 233 | "False\n" 234 | ] 235 | } 236 | ], 237 | "source": [ 238 | "print(res1(5))\n", 239 | "print(res2(5))" 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": null, 245 | "id": "499a25b1", 246 | "metadata": {}, 247 | "outputs": [], 248 | "source": [ 249 | "def myfunc(n):\n", 250 | " return lambda a : a * n\n", 251 | "\n", 252 | "mydoubler = myfunc(2)\n", 253 | "mytripler = myfunc(3)\n", 254 | "\n", 255 | "print(mydoubler(11))\n", 256 | "print(mytripler(11))" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "id": "d7e83086", 263 | "metadata": {}, 264 | "outputs": [], 265 | "source": [] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": 22, 270 | "id": "0b2c354e", 271 | "metadata": {}, 272 | "outputs": [ 273 | { 274 | "name": "stdout", 275 | "output_type": "stream", 276 | "text": [ 277 | "hello dear student\n" 278 | ] 279 | } 280 | ], 281 | "source": [ 282 | "#no return no args\n", 283 | "def show():\n", 284 | " print(\"hello dear student\")\n", 285 | " \n", 286 | "show()" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": null, 292 | "id": "1bb8315c", 293 | "metadata": {}, 294 | "outputs": [], 295 | "source": [ 296 | "#no return but args" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": 23, 302 | "id": "d2290389", 303 | "metadata": {}, 304 | "outputs": [ 305 | { 306 | "name": "stdout", 307 | "output_type": "stream", 308 | "text": [ 309 | "hello dear ram\n" 310 | ] 311 | } 312 | ], 313 | "source": [ 314 | "def show(name):\n", 315 | " print(\"hello dear\",name)\n", 316 | " \n", 317 | "show(\"ram\")" 318 | ] 319 | }, 320 | { 321 | "cell_type": "code", 322 | "execution_count": null, 323 | "id": "b6711ba6", 324 | "metadata": {}, 325 | "outputs": [], 326 | "source": [ 327 | "#return no args" 328 | ] 329 | }, 330 | { 331 | "cell_type": "code", 332 | "execution_count": null, 333 | "id": "cdd1ba36", 334 | "metadata": {}, 335 | "outputs": [], 336 | "source": [ 337 | "def show():\n", 338 | " return \"asterisc\"\n", 339 | " \n", 340 | "x=show()\n", 341 | "print(x)" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": null, 347 | "id": "307b9797", 348 | "metadata": {}, 349 | "outputs": [], 350 | "source": [ 351 | "#return & args" 352 | ] 353 | }, 354 | { 355 | "cell_type": "code", 356 | "execution_count": 24, 357 | "id": "29d486a2", 358 | "metadata": {}, 359 | "outputs": [ 360 | { 361 | "name": "stdout", 362 | "output_type": "stream", 363 | "text": [ 364 | "hello dear ram\n" 365 | ] 366 | } 367 | ], 368 | "source": [ 369 | "def show(name):\n", 370 | " return \"hello dear \"+name;\n", 371 | " \n", 372 | "x = show(\"ram\")\n", 373 | "print(x)" 374 | ] 375 | }, 376 | { 377 | "cell_type": "code", 378 | "execution_count": null, 379 | "id": "61310cc0", 380 | "metadata": {}, 381 | "outputs": [ 382 | { 383 | "name": "stdout", 384 | "output_type": "stream", 385 | "text": [ 386 | "hello dear\n", 387 | "hello dear\n", 388 | "hello dear\n", 389 | "hello dear\n", 390 | "hello dear\n", 391 | "hello dear\n", 392 | "hello dear\n", 393 | "hello dear\n", 394 | "hello dear\n", 395 | "hello dear\n", 396 | "hello dear\n", 397 | "hello dear\n", 398 | "continue......" 399 | ] 400 | } 401 | ], 402 | "source": [ 403 | "def show():\n", 404 | " print(\"hello dear\")\n", 405 | " show()\n", 406 | " \n", 407 | "show()" 408 | ] 409 | }, 410 | { 411 | "cell_type": "code", 412 | "execution_count": null, 413 | "id": "b95625f6", 414 | "metadata": {}, 415 | "outputs": [], 416 | "source": [] 417 | }, 418 | { 419 | "cell_type": "code", 420 | "execution_count": null, 421 | "id": "857121d3", 422 | "metadata": {}, 423 | "outputs": [], 424 | "source": [] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": null, 429 | "id": "a0fabaed", 430 | "metadata": {}, 431 | "outputs": [], 432 | "source": [] 433 | }, 434 | { 435 | "cell_type": "code", 436 | "execution_count": null, 437 | "id": "e7aa5a9d", 438 | "metadata": {}, 439 | "outputs": [], 440 | "source": [] 441 | }, 442 | { 443 | "cell_type": "code", 444 | "execution_count": null, 445 | "id": "d19b02e1", 446 | "metadata": {}, 447 | "outputs": [], 448 | "source": [] 449 | } 450 | ], 451 | "metadata": { 452 | "kernelspec": { 453 | "display_name": "Python 3 (ipykernel)", 454 | "language": "python", 455 | "name": "python3" 456 | }, 457 | "language_info": { 458 | "codemirror_mode": { 459 | "name": "ipython", 460 | "version": 3 461 | }, 462 | "file_extension": ".py", 463 | "mimetype": "text/x-python", 464 | "name": "python", 465 | "nbconvert_exporter": "python", 466 | "pygments_lexer": "ipython3", 467 | "version": "3.10.3" 468 | } 469 | }, 470 | "nbformat": 4, 471 | "nbformat_minor": 5 472 | } 473 | -------------------------------------------------------------------------------- /Day 01/NoteBook1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "3c1c149f", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Variables\n", 9 | "\n", 10 | "Variables are containers for storing data values." 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "id": "39c51e66", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "#Creating Variables" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "id": "ae786109", 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "id": "377e2225", 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "#Get the Type" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "id": "f6600f96", 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "id": "da0e02a4", 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "#Casting" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "id": "92f83070", 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "id": "85e28dc7", 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "#Single or Double Quotes? String" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "id": "132b1119", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "id": "256ff51c", 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "#Case-Sensitive" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "cf03338e", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "id": "e3692ce1", 106 | "metadata": {}, 107 | "source": [ 108 | "# identifier (Variable Names)\n", 109 | "A variable can have a short name (like x and y) or\n", 110 | "a more descriptive name (age, carname, total_volume). \n", 111 | "\n", 112 | "Rules for Python variables:\n", 113 | "A variable name must start with a letter or the underscore character\n", 114 | "A variable name cannot start with a number\n", 115 | "A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )\n", 116 | "Variable names are case-sensitive (age, Age and AGE are three different variables)" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "id": "904b5dde", 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": null, 130 | "id": "b11052ba", 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [ 134 | "#Multi Words Variable Names" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "id": "8e35e45f", 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": null, 148 | "id": "51722400", 149 | "metadata": {}, 150 | "outputs": [], 151 | "source": [ 152 | "#Camel Case:- Each word, except the first, starts with a capital letter:" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "id": "c9f972be", 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "id": "c0874cd4", 167 | "metadata": {}, 168 | "outputs": [], 169 | "source": [ 170 | "#Pascal Case:- Each word starts with a capital letter:" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "id": "a2701b83", 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": null, 184 | "id": "959b3293", 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "#Snake_Case:- Each word is separated by an underscore '_' character:" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "id": "f8ebf35e", 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": null, 202 | "id": "5796742b", 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "#Many Values to Multiple Variables" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "id": "e8a2ba10", 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": null, 220 | "id": "e01f5836", 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [ 224 | "#One Value to Multiple Variables" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": null, 230 | "id": "fad21e38", 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "id": "4edc4972", 238 | "metadata": {}, 239 | "source": [ 240 | "# OUTPUT Statment\n", 241 | "\n", 242 | "The Python print() function is often used to output variables." 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": null, 248 | "id": "3fb00f73", 249 | "metadata": {}, 250 | "outputs": [], 251 | "source": [] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "id": "042386e2", 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "#Output multiple variables, separated by a comma:" 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": null, 266 | "id": "45d225e1", 267 | "metadata": {}, 268 | "outputs": [], 269 | "source": [] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "id": "1ed5c9a9", 275 | "metadata": {}, 276 | "outputs": [], 277 | "source": [ 278 | "#use the + operator to output multiple variables:" 279 | ] 280 | }, 281 | { 282 | "cell_type": "code", 283 | "execution_count": null, 284 | "id": "63c5ec6b", 285 | "metadata": {}, 286 | "outputs": [], 287 | "source": [] 288 | }, 289 | { 290 | "cell_type": "markdown", 291 | "id": "9e7a1edc", 292 | "metadata": {}, 293 | "source": [ 294 | "# Input Statment\n", 295 | "\n", 296 | "The Python input(Message) function allows user input." 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": null, 302 | "id": "34a97764", 303 | "metadata": {}, 304 | "outputs": [], 305 | "source": [ 306 | "# String Input" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": null, 312 | "id": "3472d463", 313 | "metadata": {}, 314 | "outputs": [], 315 | "source": [] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": null, 320 | "id": "5771bc35", 321 | "metadata": {}, 322 | "outputs": [], 323 | "source": [ 324 | "# Integer Input " 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": null, 330 | "id": "1164a5b1", 331 | "metadata": {}, 332 | "outputs": [], 333 | "source": [] 334 | }, 335 | { 336 | "cell_type": "code", 337 | "execution_count": null, 338 | "id": "56e9de67", 339 | "metadata": {}, 340 | "outputs": [], 341 | "source": [ 342 | "# Float Input " 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": null, 348 | "id": "882544a1", 349 | "metadata": {}, 350 | "outputs": [], 351 | "source": [] 352 | }, 353 | { 354 | "cell_type": "markdown", 355 | "id": "e6a996e5", 356 | "metadata": {}, 357 | "source": [ 358 | "# Python Data Types\n", 359 | "\n", 360 | "Built-in Data Types\n", 361 | "In programming, data type is an important concept.\n", 362 | "\n", 363 | "Variables can store data of different types, and different types can do different things.\n", 364 | "\n", 365 | "Python has the following data types built-in by default, in these categories:\n", 366 | "\n", 367 | "Text Type:\tstr\n", 368 | "\n", 369 | "Numeric Types:\tint, float, complex\n", 370 | "\n", 371 | "Sequence Types:\tlist, tuple, range\n", 372 | "\n", 373 | "Mapping Type:\tdict\n", 374 | "\n", 375 | "Set Types:\tset\n", 376 | "\n", 377 | "Boolean Type:\tbool\n", 378 | "\n", 379 | "Binary Types:\tbytes" 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": null, 385 | "id": "69360723", 386 | "metadata": {}, 387 | "outputs": [], 388 | "source": [] 389 | }, 390 | { 391 | "cell_type": "markdown", 392 | "id": "39a9d271", 393 | "metadata": {}, 394 | "source": [ 395 | "# Python Operators\n", 396 | "\n", 397 | "Operators are used to perform operations on variables and values." 398 | ] 399 | }, 400 | { 401 | "cell_type": "code", 402 | "execution_count": null, 403 | "id": "06fe40c5", 404 | "metadata": {}, 405 | "outputs": [], 406 | "source": [ 407 | "#Python Arithmetic Operators\n", 408 | "\n", 409 | "Arithmetic operators are used with numeric values to perform common mathematical operations:\n", 410 | " + - * / % ** //" 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "execution_count": null, 416 | "id": "9ee401c9", 417 | "metadata": {}, 418 | "outputs": [], 419 | "source": [] 420 | }, 421 | { 422 | "cell_type": "markdown", 423 | "id": "9a9ad437", 424 | "metadata": {}, 425 | "source": [ 426 | "# -------------------------------------Page End-------------------------------------\n", 427 | "Asterisc.in \n", 428 | "We will help you bring out the best in you...!! \n", 429 | "Industrial Training / Internship / College Projects\n", 430 | "Contact 7744822228 / 7743822228 \n", 431 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 432 | ] 433 | } 434 | ], 435 | "metadata": { 436 | "kernelspec": { 437 | "display_name": "Python 3 (ipykernel)", 438 | "language": "python", 439 | "name": "python3" 440 | }, 441 | "language_info": { 442 | "codemirror_mode": { 443 | "name": "ipython", 444 | "version": 3 445 | }, 446 | "file_extension": ".py", 447 | "mimetype": "text/x-python", 448 | "name": "python", 449 | "nbconvert_exporter": "python", 450 | "pygments_lexer": "ipython3", 451 | "version": "3.9.7" 452 | } 453 | }, 454 | "nbformat": 4, 455 | "nbformat_minor": 5 456 | } 457 | -------------------------------------------------------------------------------- /Day 04/Day 4 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "e624ed92", 6 | "metadata": {}, 7 | "source": [ 8 | "# Strings\n", 9 | "\n", 10 | "Strings in python are surrounded by either single quotation marks, or double quotation marks.\n", 11 | "'hello' is the same as \"hello\"\n" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 6, 17 | "id": "01a1b906", 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "a=\"hello\"\n", 22 | "b='world'\n", 23 | "c=\"215623562\"\n", 24 | "d=\"@$%&**\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "id": "e0fe9a1f", 30 | "metadata": {}, 31 | "source": [ 32 | "# String Concatenation\n", 33 | "\n", 34 | "To concatenate, or combine, two strings you can use the + operator.\n" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 14, 40 | "id": "876f615f", 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "ename": "SyntaxError", 45 | "evalue": "unterminated string literal (detected at line 1) (2413644228.py, line 1)", 46 | "output_type": "error", 47 | "traceback": [ 48 | "\u001b[1;36m Input \u001b[1;32mIn [14]\u001b[1;36m\u001b[0m\n\u001b[1;33m a=\"hello dear student your age is\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m unterminated string literal (detected at line 1)\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "a=\"hello dear student your age is \n", 54 | "dfhdjkfkj \n", 55 | "sdfhjdikfjiklef\"\n", 56 | "\n", 57 | "print(a,age)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "id": "dc4445f9", 63 | "metadata": {}, 64 | "source": [ 65 | "# Multiline Strings\n", 66 | "\n", 67 | "Three single quotes:\n" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 15, 73 | "id": "18dbea61", 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "i am chandrakant \n", 81 | "i love to coding\n", 82 | "i am from nagpur sjkdjskf\n", 83 | "sdfshjf\n", 84 | "dsfnjkejfk\n", 85 | "dfdjkfh\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "x='''i am chandrakant \n", 91 | "i love to coding\n", 92 | "i am from nagpur sjkdjskf\n", 93 | "sdfshjf\n", 94 | "dsfnjkejfk\n", 95 | "dfdjkfh'''\n", 96 | "\n", 97 | "print(x)" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 20, 103 | "id": "6e104ceb", 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "e\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "z=\"hello world fgdfgfd fghf\"\n", 116 | "print(z[1])" 117 | ] 118 | }, 119 | { 120 | "cell_type": "markdown", 121 | "id": "116d8196", 122 | "metadata": {}, 123 | "source": [ 124 | "# String Length\n", 125 | "\n", 126 | "len()\n" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 21, 132 | "id": "b17271fc", 133 | "metadata": {}, 134 | "outputs": [ 135 | { 136 | "name": "stdout", 137 | "output_type": "stream", 138 | "text": [ 139 | "24\n" 140 | ] 141 | } 142 | ], 143 | "source": [ 144 | "print(len(z))" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "id": "62d58ea0", 150 | "metadata": {}, 151 | "source": [ 152 | "# Check String\n", 153 | "\n", 154 | "we can use the keyword -> in" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 23, 160 | "id": "986b0d23", 161 | "metadata": {}, 162 | "outputs": [ 163 | { 164 | "name": "stdout", 165 | "output_type": "stream", 166 | "text": [ 167 | "False\n" 168 | ] 169 | } 170 | ], 171 | "source": [ 172 | "x=\"i am chandrakant i love python\"\n", 173 | "\n", 174 | "print(\"java\" in x)" 175 | ] 176 | }, 177 | { 178 | "cell_type": "markdown", 179 | "id": "1e7db2ab", 180 | "metadata": {}, 181 | "source": [ 182 | "# Slicing\n", 183 | "\n", 184 | "You can return a range of characters by using the slice syntax.\n", 185 | "\n", 186 | "[start index : end index]\n", 187 | "\n" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": 26, 193 | "id": "0c8b710c", 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "name": "stdout", 198 | "output_type": "stream", 199 | "text": [ 200 | "hello\n" 201 | ] 202 | } 203 | ], 204 | "source": [ 205 | "x=\"hello world\"\n", 206 | "print(x[:5])" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "id": "ddc60d64", 212 | "metadata": {}, 213 | "source": [ 214 | "# Slice From the Start\n", 215 | "\n", 216 | "[ : end index]" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "id": "48b5fd0f", 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [] 226 | }, 227 | { 228 | "cell_type": "markdown", 229 | "id": "0e74f64b", 230 | "metadata": {}, 231 | "source": [ 232 | "# Slice To the End\n", 233 | "\n", 234 | "[start index : ]" 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": null, 240 | "id": "ca130f1b", 241 | "metadata": {}, 242 | "outputs": [], 243 | "source": [] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "id": "6239d358", 248 | "metadata": {}, 249 | "source": [ 250 | "# Negative Indexing\n", 251 | "\n", 252 | "[ -start index : -end index]" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 29, 258 | "id": "a66c184e", 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "worl\n", 266 | "\n", 267 | "worl\n" 268 | ] 269 | } 270 | ], 271 | "source": [ 272 | "x=\"hello world\"\n", 273 | "\n", 274 | "print(x[-5:-1])\n", 275 | "\n", 276 | "print(x[-2:-4])\n", 277 | "\n", 278 | "print(x[-5:10])" 279 | ] 280 | }, 281 | { 282 | "cell_type": "markdown", 283 | "id": "e9a3da10", 284 | "metadata": {}, 285 | "source": [ 286 | "# Modify Strings\n", 287 | "\n", 288 | "Python has a set of built-in methods that you can use on strings." 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": null, 294 | "id": "0d6bab05", 295 | "metadata": {}, 296 | "outputs": [], 297 | "source": [ 298 | "x=\"hello world\"" 299 | ] 300 | }, 301 | { 302 | "cell_type": "code", 303 | "execution_count": null, 304 | "id": "ba44ca1d", 305 | "metadata": {}, 306 | "outputs": [], 307 | "source": [ 308 | "upper() method" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": 31, 314 | "id": "abd63d7d", 315 | "metadata": {}, 316 | "outputs": [ 317 | { 318 | "data": { 319 | "text/plain": [ 320 | "'HELLO WORLD'" 321 | ] 322 | }, 323 | "execution_count": 31, 324 | "metadata": {}, 325 | "output_type": "execute_result" 326 | } 327 | ], 328 | "source": [ 329 | "x.upper()" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": null, 335 | "id": "23c58fd9", 336 | "metadata": {}, 337 | "outputs": [], 338 | "source": [ 339 | "lower() method" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": 32, 345 | "id": "eb7fe687", 346 | "metadata": {}, 347 | "outputs": [ 348 | { 349 | "data": { 350 | "text/plain": [ 351 | "'hello world'" 352 | ] 353 | }, 354 | "execution_count": 32, 355 | "metadata": {}, 356 | "output_type": "execute_result" 357 | } 358 | ], 359 | "source": [ 360 | "x.lower()" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": null, 366 | "id": "1180824f", 367 | "metadata": {}, 368 | "outputs": [], 369 | "source": [ 370 | "strip() method Remove Whitespace" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": 35, 376 | "id": "e6fbb542", 377 | "metadata": {}, 378 | "outputs": [ 379 | { 380 | "name": "stdout", 381 | "output_type": "stream", 382 | "text": [ 383 | "hello world\n" 384 | ] 385 | } 386 | ], 387 | "source": [ 388 | "x=\" hello world \"\n", 389 | "print(x.strip())" 390 | ] 391 | }, 392 | { 393 | "cell_type": "code", 394 | "execution_count": null, 395 | "id": "83ea649d", 396 | "metadata": {}, 397 | "outputs": [], 398 | "source": [ 399 | "replace() method" 400 | ] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "execution_count": 36, 405 | "id": "bf7acc67", 406 | "metadata": {}, 407 | "outputs": [ 408 | { 409 | "name": "stdout", 410 | "output_type": "stream", 411 | "text": [ 412 | "i love java\n", 413 | "i love python\n" 414 | ] 415 | } 416 | ], 417 | "source": [ 418 | "x=\"i love java\"\n", 419 | "print(x)\n", 420 | "print(x.replace(\"java\",\"python\"))" 421 | ] 422 | }, 423 | { 424 | "cell_type": "code", 425 | "execution_count": null, 426 | "id": "c6933e3e", 427 | "metadata": {}, 428 | "outputs": [], 429 | "source": [ 430 | "split() method" 431 | ] 432 | }, 433 | { 434 | "cell_type": "code", 435 | "execution_count": 39, 436 | "id": "31a7da83", 437 | "metadata": {}, 438 | "outputs": [ 439 | { 440 | "name": "stdout", 441 | "output_type": "stream", 442 | "text": [ 443 | "['i', 'love', 'python']\n" 444 | ] 445 | } 446 | ], 447 | "source": [ 448 | "x=\"i love python\"\n", 449 | "print(x.split(\" \"))" 450 | ] 451 | }, 452 | { 453 | "cell_type": "markdown", 454 | "id": "45acecd7", 455 | "metadata": {}, 456 | "source": [ 457 | "# String Format\n", 458 | "\n", 459 | "format() method and placeholders {}" 460 | ] 461 | }, 462 | { 463 | "cell_type": "code", 464 | "execution_count": 48, 465 | "id": "61ebde34", 466 | "metadata": {}, 467 | "outputs": [ 468 | { 469 | "name": "stdout", 470 | "output_type": "stream", 471 | "text": [ 472 | "\n", 473 | "hello dear ram your roll is 222 and age is 29 and from nagpur\n" 474 | ] 475 | } 476 | ], 477 | "source": [ 478 | "a=\"hello dear {2} your roll is {0} and age is {3} and from {1}\"\n", 479 | "\n", 480 | "roll=222\n", 481 | "city=\"nagpur\"\n", 482 | "name=\"ram\"\n", 483 | "age=29\n", 484 | "\n", 485 | "print(type(age))\n", 486 | "print(a.format(roll,city,name,age))" 487 | ] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "execution_count": 50, 492 | "id": "8fa76f34", 493 | "metadata": {}, 494 | "outputs": [ 495 | { 496 | "name": "stdout", 497 | "output_type": "stream", 498 | "text": [ 499 | "world\n" 500 | ] 501 | } 502 | ], 503 | "source": [ 504 | "x=\"hello world\"\n", 505 | "print(x[1:5])" 506 | ] 507 | }, 508 | { 509 | "cell_type": "code", 510 | "execution_count": null, 511 | "id": "cdd3e0c9", 512 | "metadata": {}, 513 | "outputs": [], 514 | "source": [] 515 | } 516 | ], 517 | "metadata": { 518 | "kernelspec": { 519 | "display_name": "Python 3 (ipykernel)", 520 | "language": "python", 521 | "name": "python3" 522 | }, 523 | "language_info": { 524 | "codemirror_mode": { 525 | "name": "ipython", 526 | "version": 3 527 | }, 528 | "file_extension": ".py", 529 | "mimetype": "text/x-python", 530 | "name": "python", 531 | "nbconvert_exporter": "python", 532 | "pygments_lexer": "ipython3", 533 | "version": "3.10.3" 534 | } 535 | }, 536 | "nbformat": 4, 537 | "nbformat_minor": 5 538 | } 539 | -------------------------------------------------------------------------------- /Day 02/Notebook2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "e6a996e5", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Data Types\n", 9 | "\n", 10 | "Built-in Data Types\n", 11 | "In programming, data type is an important concept.\n", 12 | "\n", 13 | "Variables can store data of different types, and different types can do different things.\n", 14 | "\n", 15 | "Python has the following data types built-in by default\n", 16 | "\n", 17 | " Text Type:\tstr\n", 18 | "\n", 19 | " Numeric Types :\tint, float, complex\n", 20 | "\n", 21 | " Sequence Types :\tlist, tuple, range\n", 22 | "\n", 23 | " Mapping Type :\tdict\n", 24 | "\n", 25 | " Set Types :\tset\n", 26 | "\n", 27 | " Boolean Type :\tbool\n", 28 | "\n", 29 | " Binary Types :\tbytes\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "id": "9aac16f1", 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "a=10\n", 40 | "b=2.6\n", 41 | "c=\"hello\"\n", 42 | "x=\"10\"\n", 43 | "y='3.4'" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 5, 49 | "id": "15557787", 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "name=[\"ram\",\"sham\",\"geeta\",\"pooja\",\"yog\"]" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 6, 59 | "id": "a6655acd", 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "data": { 64 | "text/plain": [ 65 | "list" 66 | ] 67 | }, 68 | "execution_count": 6, 69 | "metadata": {}, 70 | "output_type": "execute_result" 71 | } 72 | ], 73 | "source": [ 74 | "type(name)" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "id": "7b592cc9", 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "a=[\"ram\",44,4.5,\"pooja\",\"yog\"]" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 7, 90 | "id": "d6c8473d", 91 | "metadata": {}, 92 | "outputs": [ 93 | { 94 | "data": { 95 | "text/plain": [ 96 | "list" 97 | ] 98 | }, 99 | "execution_count": 7, 100 | "metadata": {}, 101 | "output_type": "execute_result" 102 | } 103 | ], 104 | "source": [ 105 | "type(name)" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "id": "ce3b29da", 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [ 115 | "name=[\"ram\",44,4.5,\"pooja\",[36,6,7,7,7]]" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 10, 121 | "id": "0751b895", 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "name=[\"ram\",\"sham\",\"geeta\",\"pooja\",\"yog\",\"ram\"]" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 11, 131 | "id": "5fda1383", 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "name": "stdout", 136 | "output_type": "stream", 137 | "text": [ 138 | "['ram', 'sham', 'geeta', 'pooja', 'yog', 'ram']\n" 139 | ] 140 | } 141 | ], 142 | "source": [ 143 | "print(name)" 144 | ] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "execution_count": 12, 149 | "id": "108cb090", 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "x=[]" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 13, 159 | "id": "4990e3da", 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "data": { 164 | "text/plain": [ 165 | "list" 166 | ] 167 | }, 168 | "execution_count": 13, 169 | "metadata": {}, 170 | "output_type": "execute_result" 171 | } 172 | ], 173 | "source": [ 174 | "type(x)" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 14, 180 | "id": "c70a08f2", 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "a=()" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": 15, 190 | "id": "11cddc99", 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "data": { 195 | "text/plain": [ 196 | "tuple" 197 | ] 198 | }, 199 | "execution_count": 15, 200 | "metadata": {}, 201 | "output_type": "execute_result" 202 | } 203 | ], 204 | "source": [ 205 | "type(a)" 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": 16, 211 | "id": "6e7cce91", 212 | "metadata": {}, 213 | "outputs": [], 214 | "source": [ 215 | "b={100,20.3,\"ram\",20,\"ram\",\"geeta\",\"pooja\",\"yog\"}" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": 17, 221 | "id": "10d8172b", 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "set" 228 | ] 229 | }, 230 | "execution_count": 17, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "type(b)" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 18, 242 | "id": "575650a1", 243 | "metadata": { 244 | "scrolled": true 245 | }, 246 | "outputs": [ 247 | { 248 | "name": "stdout", 249 | "output_type": "stream", 250 | "text": [ 251 | "{'geeta', 100, 20, 20.3, 'ram', 'pooja', 'yog'}\n" 252 | ] 253 | } 254 | ], 255 | "source": [ 256 | "print(b)" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": 19, 262 | "id": "44654751", 263 | "metadata": {}, 264 | "outputs": [], 265 | "source": [ 266 | "c={'ram':28,'geeta':18,'sham':31}" 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "execution_count": 23, 272 | "id": "2a5d4685", 273 | "metadata": {}, 274 | "outputs": [], 275 | "source": [ 276 | "c={'ram':28,'geeta':18,'sham':31,\"pooja\":[]}" 277 | ] 278 | }, 279 | { 280 | "cell_type": "code", 281 | "execution_count": 20, 282 | "id": "b25ba4cf", 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "data": { 287 | "text/plain": [ 288 | "dict" 289 | ] 290 | }, 291 | "execution_count": 20, 292 | "metadata": {}, 293 | "output_type": "execute_result" 294 | } 295 | ], 296 | "source": [ 297 | "type(c)" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 24, 303 | "id": "b2c210a0", 304 | "metadata": {}, 305 | "outputs": [ 306 | { 307 | "name": "stdout", 308 | "output_type": "stream", 309 | "text": [ 310 | "{'ram': 28, 'geeta': 18, 'sham': 31, 'pooja': []}\n" 311 | ] 312 | } 313 | ], 314 | "source": [ 315 | "print(c)" 316 | ] 317 | }, 318 | { 319 | "cell_type": "code", 320 | "execution_count": 25, 321 | "id": "3ef53074", 322 | "metadata": {}, 323 | "outputs": [], 324 | "source": [ 325 | "x={ }" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": 26, 331 | "id": "f1f19a78", 332 | "metadata": {}, 333 | "outputs": [ 334 | { 335 | "data": { 336 | "text/plain": [ 337 | "dict" 338 | ] 339 | }, 340 | "execution_count": 26, 341 | "metadata": {}, 342 | "output_type": "execute_result" 343 | } 344 | ], 345 | "source": [ 346 | "type(x)" 347 | ] 348 | }, 349 | { 350 | "cell_type": "markdown", 351 | "id": "16094543", 352 | "metadata": {}, 353 | "source": [ 354 | "# Python Operators\n", 355 | "\n", 356 | "An operator in a programming language is a symbol that tells the compiler or interpreter to perform specific mathematical, relational or logical operation\n", 357 | "\n", 358 | "#following groups:\n", 359 | "\n", 360 | "1. Arithmetic operators\n", 361 | "2. Assignment operators\n", 362 | "3. Comparison operators\n", 363 | "4. Logical operators\n", 364 | "5. Identity operators\n", 365 | "6. Membership operators\n", 366 | "7. Bitwise operators" 367 | ] 368 | }, 369 | { 370 | "cell_type": "markdown", 371 | "id": "93235cca", 372 | "metadata": {}, 373 | "source": [ 374 | "# 1. Arithmetic operators\n", 375 | "Arithmetic operators are used with numeric values to perform common mathematical operations:" 376 | ] 377 | }, 378 | { 379 | "cell_type": "markdown", 380 | "id": "dd946842", 381 | "metadata": {}, 382 | "source": [ 383 | "Addition + \n", 384 | "Subtraction - \n", 385 | "Multiplication *\n", 386 | "Division /\n", 387 | "Modulus %\n", 388 | "Exponentiation **\n", 389 | "\n", 390 | "Floor division // [ the floor division // rounds the result down to the nearest whole number ]" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 7, 396 | "id": "bbc5696a", 397 | "metadata": {}, 398 | "outputs": [], 399 | "source": [ 400 | "x=15\n", 401 | "y=2" 402 | ] 403 | }, 404 | { 405 | "cell_type": "code", 406 | "execution_count": 8, 407 | "id": "dc947c24", 408 | "metadata": {}, 409 | "outputs": [ 410 | { 411 | "data": { 412 | "text/plain": [ 413 | "7" 414 | ] 415 | }, 416 | "execution_count": 8, 417 | "metadata": {}, 418 | "output_type": "execute_result" 419 | } 420 | ], 421 | "source": [ 422 | "x//y" 423 | ] 424 | }, 425 | { 426 | "cell_type": "markdown", 427 | "id": "f6474c24", 428 | "metadata": {}, 429 | "source": [ 430 | "# Python Assignment Operators\n", 431 | "\n", 432 | "= += -= *= /= %= //= **= " 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 14, 438 | "id": "7456f8c4", 439 | "metadata": {}, 440 | "outputs": [ 441 | { 442 | "name": "stdout", 443 | "output_type": "stream", 444 | "text": [ 445 | "50\n" 446 | ] 447 | } 448 | ], 449 | "source": [ 450 | "a=30\n", 451 | "b=20\n", 452 | "a+=b\n", 453 | "print(a)" 454 | ] 455 | }, 456 | { 457 | "cell_type": "markdown", 458 | "id": "1bc45c9d", 459 | "metadata": {}, 460 | "source": [ 461 | "# Python Comparison Operators\n", 462 | "\n", 463 | "== != > < >= <=" 464 | ] 465 | }, 466 | { 467 | "cell_type": "code", 468 | "execution_count": 22, 469 | "id": "85dc56a0", 470 | "metadata": {}, 471 | "outputs": [ 472 | { 473 | "name": "stdout", 474 | "output_type": "stream", 475 | "text": [ 476 | "False\n" 477 | ] 478 | } 479 | ], 480 | "source": [ 481 | "a=30\n", 482 | "b=30\n", 483 | "\n", 484 | "print(a>b)" 485 | ] 486 | }, 487 | { 488 | "cell_type": "markdown", 489 | "id": "74bb7cdc", 490 | "metadata": {}, 491 | "source": [ 492 | "# Python Logical Operators\n", 493 | "\n", 494 | "and | or | not" 495 | ] 496 | }, 497 | { 498 | "cell_type": "code", 499 | "execution_count": 27, 500 | "id": "8fec4cf6", 501 | "metadata": {}, 502 | "outputs": [ 503 | { 504 | "name": "stdout", 505 | "output_type": "stream", 506 | "text": [ 507 | "True\n" 508 | ] 509 | } 510 | ], 511 | "source": [ 512 | "a=20\n", 513 | "b=5\n", 514 | "c=4\n", 515 | "\n", 516 | "\n", 517 | "print(not(a>\n" 610 | ] 611 | }, 612 | { 613 | "cell_type": "code", 614 | "execution_count": 50, 615 | "id": "1a2a459e", 616 | "metadata": {}, 617 | "outputs": [ 618 | { 619 | "name": "stdout", 620 | "output_type": "stream", 621 | "text": [ 622 | "5\n" 623 | ] 624 | } 625 | ], 626 | "source": [ 627 | "a=10\n", 628 | "\n", 629 | "print(a>>1)" 630 | ] 631 | }, 632 | { 633 | "cell_type": "markdown", 634 | "id": "9a9ad437", 635 | "metadata": {}, 636 | "source": [ 637 | "# -------------------------------------Page End-------------------------------------\n", 638 | "Asterisc.in \n", 639 | "We will help you bring out the best in you...!! \n", 640 | "Industrial Training / Internship / College Projects\n", 641 | "Contact 7744822228 / 7743822228 \n", 642 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 643 | ] 644 | } 645 | ], 646 | "metadata": { 647 | "kernelspec": { 648 | "display_name": "Python 3 (ipykernel)", 649 | "language": "python", 650 | "name": "python3" 651 | }, 652 | "language_info": { 653 | "codemirror_mode": { 654 | "name": "ipython", 655 | "version": 3 656 | }, 657 | "file_extension": ".py", 658 | "mimetype": "text/x-python", 659 | "name": "python", 660 | "nbconvert_exporter": "python", 661 | "pygments_lexer": "ipython3", 662 | "version": "3.10.3" 663 | } 664 | }, 665 | "nbformat": 4, 666 | "nbformat_minor": 5 667 | } 668 | -------------------------------------------------------------------------------- /Day 08/Day 8 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "afcc28c2", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Dictionary\n", 9 | "\n", 10 | "Dictionaries are used to store data values in key:value pairs.\n", 11 | "\n", 12 | "1> ordered* (Version 3.7, dictionaries are ordered. Version 3.6 and earlier, dictionaries are unordered.)\n", 13 | "2> mutable / changeable (Once a set is created, you cannot change its items, but you can remove items and add new items)\n", 14 | "3> { } or dict()\n", 15 | "4> Not Allow Duplicate Key\n", 16 | "5> unindexed" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "id": "ab5c8d6c", 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "dict" 29 | ] 30 | }, 31 | "execution_count": 1, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "x={\"name\":\"ram\",\"roll\":101,\"result\":89.7 ,\"address\":\"nagpur\"}\n", 38 | "type(x)" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "id": "e76a2ea2", 44 | "metadata": {}, 45 | "source": [ 46 | "# Access Items\n", 47 | "\n", 48 | "Indexing dict[\"key\"]\n", 49 | "dict.get(\"key\") return value\n", 50 | "\n", 51 | "list of the keys:\n", 52 | "dict.keys()\n", 53 | "\n", 54 | "list of the values:\n", 55 | "dict.values()\n", 56 | "\n", 57 | "list of the key:value pairs\n", 58 | "dict.items()\n", 59 | "\n", 60 | "Check\n", 61 | "Check if Item Exists --> in" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 4, 67 | "id": "2ac83562", 68 | "metadata": {}, 69 | "outputs": [ 70 | { 71 | "name": "stdout", 72 | "output_type": "stream", 73 | "text": [ 74 | "sham\n", 75 | "nagpur\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "x={\"name\":\"ram\",\"roll\":101,\"result\":89.7 ,\"address\":\"nagpur\",1:\"sham\"}\n", 81 | "\n", 82 | "print(x[1])\n", 83 | "print(x.get(\"address\"))" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 5, 89 | "id": "39c239b9", 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "dict_keys(['name', 'roll', 'result', 'address', 1])" 96 | ] 97 | }, 98 | "execution_count": 5, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "x.keys()\n" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 6, 110 | "id": "e083c024", 111 | "metadata": {}, 112 | "outputs": [ 113 | { 114 | "data": { 115 | "text/plain": [ 116 | "dict_values(['ram', 101, 89.7, 'nagpur', 'sham'])" 117 | ] 118 | }, 119 | "execution_count": 6, 120 | "metadata": {}, 121 | "output_type": "execute_result" 122 | } 123 | ], 124 | "source": [ 125 | "x.values()" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 7, 131 | "id": "b65a8bf3", 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "data": { 136 | "text/plain": [ 137 | "{'name': 'ram', 'roll': 101, 'result': 89.7, 'address': 'nagpur', 1: 'sham'}" 138 | ] 139 | }, 140 | "execution_count": 7, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "x" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 8, 152 | "id": "74f35afb", 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "data": { 157 | "text/plain": [ 158 | "dict_items([('name', 'ram'), ('roll', 101), ('result', 89.7), ('address', 'nagpur'), (1, 'sham')])" 159 | ] 160 | }, 161 | "execution_count": 8, 162 | "metadata": {}, 163 | "output_type": "execute_result" 164 | } 165 | ], 166 | "source": [ 167 | "x.items()" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "id": "9e23b40e", 173 | "metadata": {}, 174 | "source": [ 175 | "# Change Dictionary Items\n", 176 | "\n", 177 | "dict[\"key\"]=\"value\"\n", 178 | "dict.update({\"key\": value})" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 16, 184 | "id": "37bfaac1", 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [ 188 | "x={\"name\":\"ram\",\"roll\":101,\"result\":89.7 ,\"address\":\"nagpur\",1:\"sham\"}\n", 189 | "\n", 190 | "#x[\"name\"]=\"ramkumar\"\n", 191 | "\n", 192 | "x.update({\"college\":\"asterisc\"})\n" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 17, 198 | "id": "174dfc30", 199 | "metadata": {}, 200 | "outputs": [ 201 | { 202 | "data": { 203 | "text/plain": [ 204 | "{'name': 'ram',\n", 205 | " 'roll': 101,\n", 206 | " 'result': 89.7,\n", 207 | " 'address': 'nagpur',\n", 208 | " 1: 'sham',\n", 209 | " 'college': 'asterisc'}" 210 | ] 211 | }, 212 | "execution_count": 17, 213 | "metadata": {}, 214 | "output_type": "execute_result" 215 | } 216 | ], 217 | "source": [ 218 | "x" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "id": "d9f58acc", 224 | "metadata": {}, 225 | "source": [ 226 | "# Add new Item in Dictionary\n", 227 | "\n", 228 | "dict[\"new key\"] = \"value\"\n", 229 | "dict.update({\"new key\": \"value\"})" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "id": "64a78869", 236 | "metadata": {}, 237 | "outputs": [], 238 | "source": [] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "id": "c7b5b202", 243 | "metadata": {}, 244 | "source": [ 245 | "# Dictionary Method" 246 | ] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": null, 251 | "id": "dccacc0d", 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [ 255 | "dict.clear() # Removes all the elements from the dictionary" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": null, 261 | "id": "3e52a540", 262 | "metadata": {}, 263 | "outputs": [], 264 | "source": [] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": null, 269 | "id": "d88f24ff", 270 | "metadata": {}, 271 | "outputs": [], 272 | "source": [ 273 | "dict.copy() # Returns a copy of the dictionary" 274 | ] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "id": "d23ecc90", 280 | "metadata": {}, 281 | "outputs": [], 282 | "source": [] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": null, 287 | "id": "87faff45", 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "dict.fromkeys(keys) # Returns a dictionary with the specified keys and value is none" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 25, 297 | "id": "dba3c0ef", 298 | "metadata": {}, 299 | "outputs": [], 300 | "source": [ 301 | "x={1,2,3,4}\n", 302 | "y=\"not set\"\n", 303 | "z=dict.fromkeys(x,y)" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": 26, 309 | "id": "7ca019d0", 310 | "metadata": {}, 311 | "outputs": [ 312 | { 313 | "data": { 314 | "text/plain": [ 315 | "{1: 'not set', 2: 'not set', 3: 'not set', 4: 'not set'}" 316 | ] 317 | }, 318 | "execution_count": 26, 319 | "metadata": {}, 320 | "output_type": "execute_result" 321 | } 322 | ], 323 | "source": [ 324 | "z" 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": null, 330 | "id": "69b53306", 331 | "metadata": {}, 332 | "outputs": [], 333 | "source": [ 334 | "dict.pop(keyname, defaultvalue) # Removes the element with the specified key" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": 29, 340 | "id": "b141d158", 341 | "metadata": {}, 342 | "outputs": [ 343 | { 344 | "data": { 345 | "text/plain": [ 346 | "'value is not ava..'" 347 | ] 348 | }, 349 | "execution_count": 29, 350 | "metadata": {}, 351 | "output_type": "execute_result" 352 | } 353 | ], 354 | "source": [ 355 | "x={\"name\":\"ram\",\"roll\":101,\"result\":89.7 ,\"address\":\"nagpur\",1:\"sham\"}\n", 356 | "x.pop(\"std\",\"value is not ava..\")" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": 28, 362 | "id": "73a7da48", 363 | "metadata": {}, 364 | "outputs": [ 365 | { 366 | "data": { 367 | "text/plain": [ 368 | "{'roll': 101, 'result': 89.7, 'address': 'nagpur', 1: 'sham'}" 369 | ] 370 | }, 371 | "execution_count": 28, 372 | "metadata": {}, 373 | "output_type": "execute_result" 374 | } 375 | ], 376 | "source": [ 377 | "x" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "execution_count": null, 383 | "id": "15dc4933", 384 | "metadata": {}, 385 | "outputs": [], 386 | "source": [ 387 | "dict.popitem() # Removes the last inserted key-value pair" 388 | ] 389 | }, 390 | { 391 | "cell_type": "code", 392 | "execution_count": 30, 393 | "id": "c032f67e", 394 | "metadata": {}, 395 | "outputs": [ 396 | { 397 | "data": { 398 | "text/plain": [ 399 | "(1, 'sham')" 400 | ] 401 | }, 402 | "execution_count": 30, 403 | "metadata": {}, 404 | "output_type": "execute_result" 405 | } 406 | ], 407 | "source": [ 408 | "x.popitem()" 409 | ] 410 | }, 411 | { 412 | "cell_type": "code", 413 | "execution_count": 31, 414 | "id": "a360b99f", 415 | "metadata": {}, 416 | "outputs": [ 417 | { 418 | "data": { 419 | "text/plain": [ 420 | "{'name': 'ram', 'roll': 101, 'result': 89.7, 'address': 'nagpur'}" 421 | ] 422 | }, 423 | "execution_count": 31, 424 | "metadata": {}, 425 | "output_type": "execute_result" 426 | } 427 | ], 428 | "source": [ 429 | "x" 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "execution_count": null, 435 | "id": "9afa9494", 436 | "metadata": {}, 437 | "outputs": [], 438 | "source": [ 439 | "dict.setdefault(keyname, value) \n", 440 | "#Returns the value of the specified key. If the key does not exist: insert the key, with the specified value" 441 | ] 442 | }, 443 | { 444 | "cell_type": "code", 445 | "execution_count": 35, 446 | "id": "89797783", 447 | "metadata": {}, 448 | "outputs": [ 449 | { 450 | "data": { 451 | "text/plain": [ 452 | "'not created yet'" 453 | ] 454 | }, 455 | "execution_count": 35, 456 | "metadata": {}, 457 | "output_type": "execute_result" 458 | } 459 | ], 460 | "source": [ 461 | "x.setdefault(\"std\",\"not created yet\")" 462 | ] 463 | }, 464 | { 465 | "cell_type": "code", 466 | "execution_count": 36, 467 | "id": "3b20d139", 468 | "metadata": {}, 469 | "outputs": [ 470 | { 471 | "data": { 472 | "text/plain": [ 473 | "{'name': 'ram',\n", 474 | " 'roll': 101,\n", 475 | " 'result': 89.7,\n", 476 | " 'address': 'nagpur',\n", 477 | " 'std': 'not created yet'}" 478 | ] 479 | }, 480 | "execution_count": 36, 481 | "metadata": {}, 482 | "output_type": "execute_result" 483 | } 484 | ], 485 | "source": [ 486 | "x" 487 | ] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "execution_count": null, 492 | "id": "07b8c905", 493 | "metadata": {}, 494 | "outputs": [], 495 | "source": [] 496 | }, 497 | { 498 | "cell_type": "code", 499 | "execution_count": null, 500 | "id": "502938ac", 501 | "metadata": {}, 502 | "outputs": [], 503 | "source": [] 504 | }, 505 | { 506 | "cell_type": "markdown", 507 | "id": "61e0051b", 508 | "metadata": {}, 509 | "source": [ 510 | "# Boolean Values\n", 511 | "\n", 512 | "Booleans represent one of two values: True or False." 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 37, 518 | "id": "44ecb656", 519 | "metadata": {}, 520 | "outputs": [ 521 | { 522 | "name": "stdout", 523 | "output_type": "stream", 524 | "text": [ 525 | "True\n", 526 | "False\n", 527 | "False\n" 528 | ] 529 | } 530 | ], 531 | "source": [ 532 | "print(10 > 9)\n", 533 | "print(10 == 9)\n", 534 | "print(10 < 9)" 535 | ] 536 | }, 537 | { 538 | "cell_type": "code", 539 | "execution_count": null, 540 | "id": "530d9b0e", 541 | "metadata": {}, 542 | "outputs": [], 543 | "source": [] 544 | }, 545 | { 546 | "cell_type": "code", 547 | "execution_count": 38, 548 | "id": "196ccd1f", 549 | "metadata": {}, 550 | "outputs": [ 551 | { 552 | "name": "stdout", 553 | "output_type": "stream", 554 | "text": [ 555 | "True\n", 556 | "True\n" 557 | ] 558 | } 559 | ], 560 | "source": [ 561 | "print(bool(\"Hello\"))\n", 562 | "print(bool(-15))" 563 | ] 564 | }, 565 | { 566 | "cell_type": "code", 567 | "execution_count": null, 568 | "id": "4ce39a53", 569 | "metadata": {}, 570 | "outputs": [], 571 | "source": [] 572 | }, 573 | { 574 | "cell_type": "code", 575 | "execution_count": 40, 576 | "id": "dc492466", 577 | "metadata": {}, 578 | "outputs": [ 579 | { 580 | "name": "stdout", 581 | "output_type": "stream", 582 | "text": [ 583 | "False\n", 584 | "False\n", 585 | "False\n", 586 | "False\n", 587 | "False\n", 588 | "False\n", 589 | "False\n" 590 | ] 591 | } 592 | ], 593 | "source": [ 594 | "print(bool(False))\n", 595 | "print(bool(None))\n", 596 | "print(bool(0))\n", 597 | "print(bool(\"\"))\n", 598 | "print(bool(()))\n", 599 | "print(bool([]))\n", 600 | "print(bool({}))" 601 | ] 602 | }, 603 | { 604 | "cell_type": "markdown", 605 | "id": "5e04f2cd", 606 | "metadata": {}, 607 | "source": [ 608 | "# -------------------------------------Page End-------------------------------------\n", 609 | "Asterisc.in \n", 610 | "We will help you bring out the best in you...!! \n", 611 | "Industrial Training / Internship / College Projects\n", 612 | "Contact 7744822228 / 7743822228 \n", 613 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 614 | ] 615 | } 616 | ], 617 | "metadata": { 618 | "kernelspec": { 619 | "display_name": "Python 3 (ipykernel)", 620 | "language": "python", 621 | "name": "python3" 622 | }, 623 | "language_info": { 624 | "codemirror_mode": { 625 | "name": "ipython", 626 | "version": 3 627 | }, 628 | "file_extension": ".py", 629 | "mimetype": "text/x-python", 630 | "name": "python", 631 | "nbconvert_exporter": "python", 632 | "pygments_lexer": "ipython3", 633 | "version": "3.10.3" 634 | } 635 | }, 636 | "nbformat": 4, 637 | "nbformat_minor": 5 638 | } 639 | -------------------------------------------------------------------------------- /Day 05/Day 5 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "48e2f4f2", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Lists\n", 9 | "\n", 10 | "Lists are used to store multiple items in a single variable.\n", 11 | "\n", 12 | "1> Ordered\n", 13 | "2> Mutable\n", 14 | "3> [] or list()\n", 15 | "4> Allow Duplicate" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 3, 21 | "id": "578206a9", 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "list" 28 | ] 29 | }, 30 | "execution_count": 3, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "x=[1,2,34,45,56,6,7,7]\n", 37 | "y=list()\n", 38 | "\n", 39 | "type(y)" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "id": "9d7ab3b1", 45 | "metadata": {}, 46 | "source": [ 47 | "# Access Items\n", 48 | "\n", 49 | "Indexing [1]\n", 50 | "Negative Indexing [-1]\n", 51 | "\n", 52 | "# Slicing\n", 53 | "\n", 54 | "Range of Indexes [2:5]\n", 55 | "Range of Negative Indexes[-4:-1]\n", 56 | "\n", 57 | "# Check\n", 58 | "\n", 59 | "Check if Item Exists --> in" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 9, 65 | "id": "a04a5582", 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "name": "stdout", 70 | "output_type": "stream", 71 | "text": [ 72 | "[]\n" 73 | ] 74 | } 75 | ], 76 | "source": [ 77 | "x=[1,2,34,45,56,6,7,7]\n", 78 | "print(x[-5:-6])" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "id": "6a548f8c", 84 | "metadata": {}, 85 | "source": [ 86 | "# List Methods" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "id": "1507fd1f", 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "len(iterable) # many items a list has" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 10, 102 | "id": "1ae22eef", 103 | "metadata": {}, 104 | "outputs": [ 105 | { 106 | "name": "stdout", 107 | "output_type": "stream", 108 | "text": [ 109 | "8\n" 110 | ] 111 | } 112 | ], 113 | "source": [ 114 | "print(len(x))" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "id": "894195b1", 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "append(element) # Adds an element at the end of the list" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 13, 130 | "id": "c2dfe407", 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "name": "stdout", 135 | "output_type": "stream", 136 | "text": [ 137 | "[1, 2, 34, 45, 56, 6, 7, 7, 99, 99, 99]\n" 138 | ] 139 | } 140 | ], 141 | "source": [ 142 | "x.append(99)\n", 143 | "\n", 144 | "print(x)" 145 | ] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "id": "ca8eff82", 151 | "metadata": {}, 152 | "outputs": [], 153 | "source": [ 154 | "clear() # Removes all the elements from the list" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 14, 160 | "id": "a3ec8298", 161 | "metadata": {}, 162 | "outputs": [], 163 | "source": [ 164 | "x.clear()" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 20, 170 | "id": "e1c3bb5d", 171 | "metadata": {}, 172 | "outputs": [], 173 | "source": [ 174 | "x=[1,2,34,45,56,6,7,7]" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 21, 180 | "id": "e3f69bd2", 181 | "metadata": {}, 182 | "outputs": [ 183 | { 184 | "data": { 185 | "text/plain": [ 186 | "[1, 2, 34, 45, 56, 6, 7, 7]" 187 | ] 188 | }, 189 | "execution_count": 21, 190 | "metadata": {}, 191 | "output_type": "execute_result" 192 | } 193 | ], 194 | "source": [ 195 | "x" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 22, 201 | "id": "3f677548", 202 | "metadata": {}, 203 | "outputs": [], 204 | "source": [ 205 | "x.append(55)" 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": 23, 211 | "id": "89d0d04f", 212 | "metadata": {}, 213 | "outputs": [ 214 | { 215 | "data": { 216 | "text/plain": [ 217 | "[1, 2, 34, 45, 56, 6, 7, 7, 55]" 218 | ] 219 | }, 220 | "execution_count": 23, 221 | "metadata": {}, 222 | "output_type": "execute_result" 223 | } 224 | ], 225 | "source": [ 226 | "x" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": null, 232 | "id": "c3fff132", 233 | "metadata": {}, 234 | "outputs": [], 235 | "source": [ 236 | "copy() # Returns a copy of the list" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 24, 242 | "id": "8cb7d8ba", 243 | "metadata": {}, 244 | "outputs": [], 245 | "source": [ 246 | "y=x.copy()" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 25, 252 | "id": "efb93e14", 253 | "metadata": {}, 254 | "outputs": [ 255 | { 256 | "data": { 257 | "text/plain": [ 258 | "[1, 2, 34, 45, 56, 6, 7, 7, 55]" 259 | ] 260 | }, 261 | "execution_count": 25, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "y" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": null, 273 | "id": "17c982d3", 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "count(value) # Returns the number of elements with the specified value" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 26, 283 | "id": "73b59d7d", 284 | "metadata": {}, 285 | "outputs": [], 286 | "source": [ 287 | "a=x.count(7)" 288 | ] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "execution_count": 27, 293 | "id": "d95b8523", 294 | "metadata": {}, 295 | "outputs": [ 296 | { 297 | "data": { 298 | "text/plain": [ 299 | "2" 300 | ] 301 | }, 302 | "execution_count": 27, 303 | "metadata": {}, 304 | "output_type": "execute_result" 305 | } 306 | ], 307 | "source": [ 308 | "a" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "id": "616e5104", 315 | "metadata": {}, 316 | "outputs": [], 317 | "source": [ 318 | "extend(iterable) # Add the elements of a list to the end of the current list" 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "execution_count": 28, 324 | "id": "64c62fd4", 325 | "metadata": {}, 326 | "outputs": [ 327 | { 328 | "data": { 329 | "text/plain": [ 330 | "[1, 2, 34, 45, 56, 6, 7, 7, 55]" 331 | ] 332 | }, 333 | "execution_count": 28, 334 | "metadata": {}, 335 | "output_type": "execute_result" 336 | } 337 | ], 338 | "source": [ 339 | "x" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": 30, 345 | "id": "57d46b35", 346 | "metadata": {}, 347 | "outputs": [], 348 | "source": [ 349 | "k=[33,55,676,777]" 350 | ] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "execution_count": 31, 355 | "id": "9a4c3341", 356 | "metadata": {}, 357 | "outputs": [], 358 | "source": [ 359 | "x.extend(k)" 360 | ] 361 | }, 362 | { 363 | "cell_type": "code", 364 | "execution_count": 32, 365 | "id": "d22da745", 366 | "metadata": {}, 367 | "outputs": [ 368 | { 369 | "data": { 370 | "text/plain": [ 371 | "[1, 2, 34, 45, 56, 6, 7, 7, 55, 33, 55, 676, 777]" 372 | ] 373 | }, 374 | "execution_count": 32, 375 | "metadata": {}, 376 | "output_type": "execute_result" 377 | } 378 | ], 379 | "source": [ 380 | "x" 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "execution_count": null, 386 | "id": "ba980f6c", 387 | "metadata": {}, 388 | "outputs": [], 389 | "source": [ 390 | "index(element) # Returns the index of the first element with the specified value" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 36, 396 | "id": "f7186223", 397 | "metadata": {}, 398 | "outputs": [ 399 | { 400 | "name": "stdout", 401 | "output_type": "stream", 402 | "text": [ 403 | "6\n" 404 | ] 405 | } 406 | ], 407 | "source": [ 408 | "print(x.index(7))" 409 | ] 410 | }, 411 | { 412 | "cell_type": "code", 413 | "execution_count": null, 414 | "id": "23abadf9", 415 | "metadata": {}, 416 | "outputs": [], 417 | "source": [ 418 | "insert(position, element) # Adds an element at the specified position" 419 | ] 420 | }, 421 | { 422 | "cell_type": "code", 423 | "execution_count": 37, 424 | "id": "bb542a7f", 425 | "metadata": {}, 426 | "outputs": [ 427 | { 428 | "data": { 429 | "text/plain": [ 430 | "[1, 2, 34, 45, 56, 6, 7, 7, 55, 33, 55, 676, 777]" 431 | ] 432 | }, 433 | "execution_count": 37, 434 | "metadata": {}, 435 | "output_type": "execute_result" 436 | } 437 | ], 438 | "source": [ 439 | "x" 440 | ] 441 | }, 442 | { 443 | "cell_type": "code", 444 | "execution_count": 38, 445 | "id": "f66aa393", 446 | "metadata": {}, 447 | "outputs": [], 448 | "source": [ 449 | "x.insert(3,40)" 450 | ] 451 | }, 452 | { 453 | "cell_type": "code", 454 | "execution_count": 39, 455 | "id": "267039af", 456 | "metadata": {}, 457 | "outputs": [ 458 | { 459 | "data": { 460 | "text/plain": [ 461 | "[1, 2, 34, 40, 45, 56, 6, 7, 7, 55, 33, 55, 676, 777]" 462 | ] 463 | }, 464 | "execution_count": 39, 465 | "metadata": {}, 466 | "output_type": "execute_result" 467 | } 468 | ], 469 | "source": [ 470 | "x" 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "execution_count": null, 476 | "id": "b7e22557", 477 | "metadata": {}, 478 | "outputs": [], 479 | "source": [ 480 | "pop(position) # Removes the element at the specified position" 481 | ] 482 | }, 483 | { 484 | "cell_type": "code", 485 | "execution_count": 40, 486 | "id": "8c1016e3", 487 | "metadata": {}, 488 | "outputs": [ 489 | { 490 | "data": { 491 | "text/plain": [ 492 | "45" 493 | ] 494 | }, 495 | "execution_count": 40, 496 | "metadata": {}, 497 | "output_type": "execute_result" 498 | } 499 | ], 500 | "source": [ 501 | "x.pop(4)" 502 | ] 503 | }, 504 | { 505 | "cell_type": "code", 506 | "execution_count": 41, 507 | "id": "c66f7d20", 508 | "metadata": {}, 509 | "outputs": [ 510 | { 511 | "data": { 512 | "text/plain": [ 513 | "[1, 2, 34, 40, 56, 6, 7, 7, 55, 33, 55, 676, 777]" 514 | ] 515 | }, 516 | "execution_count": 41, 517 | "metadata": {}, 518 | "output_type": "execute_result" 519 | } 520 | ], 521 | "source": [ 522 | "x" 523 | ] 524 | }, 525 | { 526 | "cell_type": "code", 527 | "execution_count": null, 528 | "id": "1e6fc98c", 529 | "metadata": {}, 530 | "outputs": [], 531 | "source": [ 532 | "remove(element) # Removes the item with the specified value" 533 | ] 534 | }, 535 | { 536 | "cell_type": "code", 537 | "execution_count": 42, 538 | "id": "2765d6a6", 539 | "metadata": {}, 540 | "outputs": [], 541 | "source": [] 542 | }, 543 | { 544 | "cell_type": "code", 545 | "execution_count": 44, 546 | "id": "4de3b57f", 547 | "metadata": {}, 548 | "outputs": [], 549 | "source": [ 550 | "x.append(7)" 551 | ] 552 | }, 553 | { 554 | "cell_type": "code", 555 | "execution_count": 45, 556 | "id": "2c5c6092", 557 | "metadata": {}, 558 | "outputs": [ 559 | { 560 | "data": { 561 | "text/plain": [ 562 | "[1, 2, 34, 40, 56, 6, 7, 55, 33, 55, 676, 777, 7]" 563 | ] 564 | }, 565 | "execution_count": 45, 566 | "metadata": {}, 567 | "output_type": "execute_result" 568 | } 569 | ], 570 | "source": [ 571 | "x" 572 | ] 573 | }, 574 | { 575 | "cell_type": "code", 576 | "execution_count": 46, 577 | "id": "3c7408d1", 578 | "metadata": {}, 579 | "outputs": [], 580 | "source": [ 581 | "x.remove(7)" 582 | ] 583 | }, 584 | { 585 | "cell_type": "code", 586 | "execution_count": 47, 587 | "id": "11a16771", 588 | "metadata": {}, 589 | "outputs": [ 590 | { 591 | "data": { 592 | "text/plain": [ 593 | "[1, 2, 34, 40, 56, 6, 55, 33, 55, 676, 777, 7]" 594 | ] 595 | }, 596 | "execution_count": 47, 597 | "metadata": {}, 598 | "output_type": "execute_result" 599 | } 600 | ], 601 | "source": [ 602 | "x" 603 | ] 604 | }, 605 | { 606 | "cell_type": "code", 607 | "execution_count": null, 608 | "id": "17400d2c", 609 | "metadata": {}, 610 | "outputs": [], 611 | "source": [ 612 | "reverse() # Reverses the order of the list" 613 | ] 614 | }, 615 | { 616 | "cell_type": "code", 617 | "execution_count": 48, 618 | "id": "1716b82c", 619 | "metadata": {}, 620 | "outputs": [], 621 | "source": [ 622 | "x.reverse()" 623 | ] 624 | }, 625 | { 626 | "cell_type": "code", 627 | "execution_count": 49, 628 | "id": "c548fb57", 629 | "metadata": {}, 630 | "outputs": [ 631 | { 632 | "data": { 633 | "text/plain": [ 634 | "[7, 777, 676, 55, 33, 55, 6, 56, 40, 34, 2, 1]" 635 | ] 636 | }, 637 | "execution_count": 49, 638 | "metadata": {}, 639 | "output_type": "execute_result" 640 | } 641 | ], 642 | "source": [ 643 | "x" 644 | ] 645 | }, 646 | { 647 | "cell_type": "code", 648 | "execution_count": null, 649 | "id": "32d81246", 650 | "metadata": {}, 651 | "outputs": [], 652 | "source": [ 653 | "sort() # Sorts the list" 654 | ] 655 | }, 656 | { 657 | "cell_type": "code", 658 | "execution_count": 50, 659 | "id": "bc07ac25", 660 | "metadata": {}, 661 | "outputs": [], 662 | "source": [ 663 | "x.sort()" 664 | ] 665 | }, 666 | { 667 | "cell_type": "code", 668 | "execution_count": 51, 669 | "id": "755a3ef4", 670 | "metadata": {}, 671 | "outputs": [ 672 | { 673 | "data": { 674 | "text/plain": [ 675 | "[1, 2, 6, 7, 33, 34, 40, 55, 55, 56, 676, 777]" 676 | ] 677 | }, 678 | "execution_count": 51, 679 | "metadata": {}, 680 | "output_type": "execute_result" 681 | } 682 | ], 683 | "source": [ 684 | "x" 685 | ] 686 | }, 687 | { 688 | "cell_type": "code", 689 | "execution_count": 57, 690 | "id": "84f33b36", 691 | "metadata": {}, 692 | "outputs": [], 693 | "source": [ 694 | "name=[\"ram\",\"sham\",\"pooja\",\"rohit\",\"yash\",30,49,45656]" 695 | ] 696 | }, 697 | { 698 | "cell_type": "code", 699 | "execution_count": 58, 700 | "id": "59ae34eb", 701 | "metadata": {}, 702 | "outputs": [ 703 | { 704 | "ename": "TypeError", 705 | "evalue": "'<' not supported between instances of 'int' and 'str'", 706 | "output_type": "error", 707 | "traceback": [ 708 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 709 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 710 | "Input \u001b[1;32mIn [58]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mname\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msort\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(name)\n", 711 | "\u001b[1;31mTypeError\u001b[0m: '<' not supported between instances of 'int' and 'str'" 712 | ] 713 | } 714 | ], 715 | "source": [ 716 | "name.sort()\n", 717 | "print(name)" 718 | ] 719 | }, 720 | { 721 | "cell_type": "code", 722 | "execution_count": null, 723 | "id": "d89e5ce6", 724 | "metadata": {}, 725 | "outputs": [], 726 | "source": [ 727 | "44,5" 728 | ] 729 | }, 730 | { 731 | "cell_type": "markdown", 732 | "id": "9a9ad437", 733 | "metadata": {}, 734 | "source": [ 735 | "# -------------------------------------Page End-------------------------------------\n", 736 | "Asterisc.in \n", 737 | "We will help you bring out the best in you...!! \n", 738 | "Industrial Training / Internship / College Projects\n", 739 | "Contact 7744822228 / 7743822228 \n", 740 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 741 | ] 742 | } 743 | ], 744 | "metadata": { 745 | "kernelspec": { 746 | "display_name": "Python 3 (ipykernel)", 747 | "language": "python", 748 | "name": "python3" 749 | }, 750 | "language_info": { 751 | "codemirror_mode": { 752 | "name": "ipython", 753 | "version": 3 754 | }, 755 | "file_extension": ".py", 756 | "mimetype": "text/x-python", 757 | "name": "python", 758 | "nbconvert_exporter": "python", 759 | "pygments_lexer": "ipython3", 760 | "version": "3.10.3" 761 | } 762 | }, 763 | "nbformat": 4, 764 | "nbformat_minor": 5 765 | } 766 | -------------------------------------------------------------------------------- /Day 07/Day 7 (Solution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "6643940e", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python Set\n", 9 | "\n", 10 | "Set are used to store multiple items in a single variable.\n", 11 | "\n", 12 | "1> Unordered (Sets are unordered, so you cannot be sure in which order the items will appear)\n", 13 | "2> immutable / Unchangeable (Once a set is created, you cannot change its items, but you can remove items and add new items)\n", 14 | "3> {} or set()\n", 15 | "4> Not Allow Duplicate\n", 16 | "5> unindexed" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 4, 22 | "id": "cc066907", 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "{'geeta', 'pooja', 'ram', 'sham'}" 29 | ] 30 | }, 31 | "execution_count": 4, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"ram\"}\n", 38 | "\n", 39 | "x" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "id": "9fd737da", 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# Check\n", 50 | "\n", 51 | "Check if Item Exists --> in" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 5, 57 | "id": "754970f5", 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "name": "stdout", 62 | "output_type": "stream", 63 | "text": [ 64 | "True\n" 65 | ] 66 | } 67 | ], 68 | "source": [ 69 | "print(\"pooja\" in x)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "id": "faa60bc9", 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [ 79 | "add() #Adds an element to the set" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 6, 85 | "id": "3be09deb", 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "x.add(\"om\")" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "id": "85a971c7", 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "id": "b42f10da", 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "clear() #Removes all the elements from the set" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": null, 113 | "id": "ad30c9b6", 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "id": "5e955ac9", 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "copy() #Returns a copy of the set" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "id": "6555a555", 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": null, 139 | "id": "c2e7e8f0", 140 | "metadata": {}, 141 | "outputs": [], 142 | "source": [ 143 | "set.discard(value) # Remove the specified item" 144 | ] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "execution_count": 9, 149 | "id": "bdd06b22", 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [ 153 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 21, 159 | "id": "ab869e76", 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [ 163 | "x.discard(\"om\")" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 22, 169 | "id": "41ad30ed", 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "data": { 174 | "text/plain": [ 175 | "{'geeta', 'pooja'}" 176 | ] 177 | }, 178 | "execution_count": 22, 179 | "metadata": {}, 180 | "output_type": "execute_result" 181 | } 182 | ], 183 | "source": [ 184 | "x" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": 23, 190 | "id": "55090684", 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "ename": "NameError", 195 | "evalue": "name 'item' is not defined", 196 | "output_type": "error", 197 | "traceback": [ 198 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 199 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 200 | "Input \u001b[1;32mIn [23]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mset\u001b[39m\u001b[38;5;241m.\u001b[39mremove(\u001b[43mitem\u001b[49m)\n", 201 | "\u001b[1;31mNameError\u001b[0m: name 'item' is not defined" 202 | ] 203 | } 204 | ], 205 | "source": [ 206 | "set.remove(item) #Remove \"item\" from the set: error if not present" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": 24, 212 | "id": "8e76f56e", 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "ename": "KeyError", 217 | "evalue": "'ram'", 218 | "output_type": "error", 219 | "traceback": [ 220 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 221 | "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", 222 | "Input \u001b[1;32mIn [24]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mx\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mremove\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mram\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", 223 | "\u001b[1;31mKeyError\u001b[0m: 'ram'" 224 | ] 225 | } 226 | ], 227 | "source": [ 228 | "x.remove(\"ram\")" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 13, 234 | "id": "89c30278", 235 | "metadata": {}, 236 | "outputs": [ 237 | { 238 | "data": { 239 | "text/plain": [ 240 | "{'geeta', 'pooja', 'sham'}" 241 | ] 242 | }, 243 | "execution_count": 13, 244 | "metadata": {}, 245 | "output_type": "execute_result" 246 | } 247 | ], 248 | "source": [ 249 | "x" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "id": "2eee1e98", 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [ 259 | "set.pop() # Remove a random item from the set and also return that item" 260 | ] 261 | }, 262 | { 263 | "cell_type": "code", 264 | "execution_count": 14, 265 | "id": "33c5b85a", 266 | "metadata": {}, 267 | "outputs": [ 268 | { 269 | "data": { 270 | "text/plain": [ 271 | "'sham'" 272 | ] 273 | }, 274 | "execution_count": 14, 275 | "metadata": {}, 276 | "output_type": "execute_result" 277 | } 278 | ], 279 | "source": [ 280 | "x.pop()" 281 | ] 282 | }, 283 | { 284 | "cell_type": "code", 285 | "execution_count": 15, 286 | "id": "33c31012", 287 | "metadata": {}, 288 | "outputs": [ 289 | { 290 | "data": { 291 | "text/plain": [ 292 | "{'geeta', 'pooja'}" 293 | ] 294 | }, 295 | "execution_count": 15, 296 | "metadata": {}, 297 | "output_type": "execute_result" 298 | } 299 | ], 300 | "source": [ 301 | "x" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "id": "1fda6010", 308 | "metadata": {}, 309 | "outputs": [], 310 | "source": [ 311 | "set.difference(set,set,nset..) #Returns a set containing the difference between two or more sets" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": 25, 317 | "id": "34b7540f", 318 | "metadata": {}, 319 | "outputs": [ 320 | { 321 | "data": { 322 | "text/plain": [ 323 | "{'geeta', 'om', 'pooja', 'sham'}" 324 | ] 325 | }, 326 | "execution_count": 25, 327 | "metadata": {}, 328 | "output_type": "execute_result" 329 | } 330 | ], 331 | "source": [ 332 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 333 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\"}\n", 334 | "\n", 335 | "z=x.difference(y)" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": 26, 341 | "id": "c33a648a", 342 | "metadata": {}, 343 | "outputs": [ 344 | { 345 | "data": { 346 | "text/plain": [ 347 | "{'geeta', 'om', 'pooja', 'ram', 'sham'}" 348 | ] 349 | }, 350 | "execution_count": 26, 351 | "metadata": {}, 352 | "output_type": "execute_result" 353 | } 354 | ], 355 | "source": [ 356 | "x" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": null, 362 | "id": "6137ead9", 363 | "metadata": {}, 364 | "outputs": [], 365 | "source": [ 366 | "set.difference_update(set) # Removes the items in this set that are also included in another, specified set" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 27, 372 | "id": "e4b5ccf7", 373 | "metadata": {}, 374 | "outputs": [], 375 | "source": [ 376 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 377 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\"}\n", 378 | "\n", 379 | "x.difference_update(y)" 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": 28, 385 | "id": "ad6fe19d", 386 | "metadata": {}, 387 | "outputs": [ 388 | { 389 | "data": { 390 | "text/plain": [ 391 | "{'geeta', 'om', 'pooja', 'sham'}" 392 | ] 393 | }, 394 | "execution_count": 28, 395 | "metadata": {}, 396 | "output_type": "execute_result" 397 | } 398 | ], 399 | "source": [ 400 | "x" 401 | ] 402 | }, 403 | { 404 | "cell_type": "code", 405 | "execution_count": null, 406 | "id": "bb9a061f", 407 | "metadata": {}, 408 | "outputs": [], 409 | "source": [ 410 | "set.intersection(set1, set2 ... etc) \n", 411 | "# Return a set that contains the items that exist in both set x, and set y:" 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": 29, 417 | "id": "5c5cc073", 418 | "metadata": {}, 419 | "outputs": [], 420 | "source": [ 421 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 422 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\"}\n", 423 | "\n", 424 | "z=x.intersection(y)" 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "execution_count": 30, 430 | "id": "7a622732", 431 | "metadata": {}, 432 | "outputs": [ 433 | { 434 | "data": { 435 | "text/plain": [ 436 | "{'ram'}" 437 | ] 438 | }, 439 | "execution_count": 30, 440 | "metadata": {}, 441 | "output_type": "execute_result" 442 | } 443 | ], 444 | "source": [ 445 | "z" 446 | ] 447 | }, 448 | { 449 | "cell_type": "code", 450 | "execution_count": 31, 451 | "id": "d1cb75bb", 452 | "metadata": {}, 453 | "outputs": [ 454 | { 455 | "data": { 456 | "text/plain": [ 457 | "{'geeta', 'om', 'pooja', 'ram', 'sham'}" 458 | ] 459 | }, 460 | "execution_count": 31, 461 | "metadata": {}, 462 | "output_type": "execute_result" 463 | } 464 | ], 465 | "source": [ 466 | "x" 467 | ] 468 | }, 469 | { 470 | "cell_type": "code", 471 | "execution_count": null, 472 | "id": "fc65e1f4", 473 | "metadata": {}, 474 | "outputs": [], 475 | "source": [ 476 | "set.intersection_update(set1, set2 ... etc) # Remove the items that is not present in both x and y:" 477 | ] 478 | }, 479 | { 480 | "cell_type": "code", 481 | "execution_count": 32, 482 | "id": "808aafbf", 483 | "metadata": {}, 484 | "outputs": [], 485 | "source": [ 486 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 487 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\"}\n", 488 | "\n", 489 | "x.intersection_update(y)" 490 | ] 491 | }, 492 | { 493 | "cell_type": "code", 494 | "execution_count": 33, 495 | "id": "7a43d720", 496 | "metadata": {}, 497 | "outputs": [ 498 | { 499 | "data": { 500 | "text/plain": [ 501 | "{'ram'}" 502 | ] 503 | }, 504 | "execution_count": 33, 505 | "metadata": {}, 506 | "output_type": "execute_result" 507 | } 508 | ], 509 | "source": [ 510 | "x" 511 | ] 512 | }, 513 | { 514 | "cell_type": "code", 515 | "execution_count": null, 516 | "id": "2317b150", 517 | "metadata": {}, 518 | "outputs": [], 519 | "source": [ 520 | "set.isdisjoint(set) # Return True if no items in set x is present in set y:" 521 | ] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "execution_count": 35, 526 | "id": "702b8a80", 527 | "metadata": {}, 528 | "outputs": [ 529 | { 530 | "data": { 531 | "text/plain": [ 532 | "True" 533 | ] 534 | }, 535 | "execution_count": 35, 536 | "metadata": {}, 537 | "output_type": "execute_result" 538 | } 539 | ], 540 | "source": [ 541 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 542 | "y={\"c\",\"c++\",\"java\",\"python\"}\n", 543 | "\n", 544 | "z=x.isdisjoint(y)\n", 545 | "\n", 546 | "z" 547 | ] 548 | }, 549 | { 550 | "cell_type": "code", 551 | "execution_count": null, 552 | "id": "cd366807", 553 | "metadata": {}, 554 | "outputs": [], 555 | "source": [ 556 | "set.issubset(set) # Return True if all items in set x are present in set y:" 557 | ] 558 | }, 559 | { 560 | "cell_type": "code", 561 | "execution_count": 37, 562 | "id": "44d81bf6", 563 | "metadata": {}, 564 | "outputs": [ 565 | { 566 | "data": { 567 | "text/plain": [ 568 | "False" 569 | ] 570 | }, 571 | "execution_count": 37, 572 | "metadata": {}, 573 | "output_type": "execute_result" 574 | } 575 | ], 576 | "source": [ 577 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 578 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\",\"sham\",\"geeta\",\"om\"}\n", 579 | "\n", 580 | "z=x.issubset(y)\n", 581 | "\n", 582 | "z" 583 | ] 584 | }, 585 | { 586 | "cell_type": "code", 587 | "execution_count": null, 588 | "id": "0e68dbee", 589 | "metadata": {}, 590 | "outputs": [], 591 | "source": [ 592 | "set.issuperset(set) # Return True if all items set y are present in set x:" 593 | ] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "execution_count": 38, 598 | "id": "4f781d75", 599 | "metadata": {}, 600 | "outputs": [ 601 | { 602 | "data": { 603 | "text/plain": [ 604 | "True" 605 | ] 606 | }, 607 | "execution_count": 38, 608 | "metadata": {}, 609 | "output_type": "execute_result" 610 | } 611 | ], 612 | "source": [ 613 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\",\"c\",\"c++\",\"java\",\"python\"}\n", 614 | "y={\"c\",\"c++\",\"java\",\"python\"}\n", 615 | "x.issuperset(y)" 616 | ] 617 | }, 618 | { 619 | "cell_type": "code", 620 | "execution_count": null, 621 | "id": "44c4e99f", 622 | "metadata": {}, 623 | "outputs": [], 624 | "source": [ 625 | "set.symmetric_difference(set)\n", 626 | "# Return a set that contains all items from both sets, except items that are present in both sets:" 627 | ] 628 | }, 629 | { 630 | "cell_type": "code", 631 | "execution_count": 39, 632 | "id": "46878b74", 633 | "metadata": {}, 634 | "outputs": [ 635 | { 636 | "data": { 637 | "text/plain": [ 638 | "{'c', 'c++', 'geeta', 'java', 'om', 'pooja', 'python'}" 639 | ] 640 | }, 641 | "execution_count": 39, 642 | "metadata": {}, 643 | "output_type": "execute_result" 644 | } 645 | ], 646 | "source": [ 647 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 648 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\",\"sham\"}\n", 649 | "\n", 650 | "z=x.symmetric_difference(y)\n", 651 | "\n", 652 | "z" 653 | ] 654 | }, 655 | { 656 | "cell_type": "code", 657 | "execution_count": 40, 658 | "id": "9e36daba", 659 | "metadata": {}, 660 | "outputs": [ 661 | { 662 | "data": { 663 | "text/plain": [ 664 | "{'geeta', 'om', 'pooja', 'ram', 'sham'}" 665 | ] 666 | }, 667 | "execution_count": 40, 668 | "metadata": {}, 669 | "output_type": "execute_result" 670 | } 671 | ], 672 | "source": [ 673 | "x" 674 | ] 675 | }, 676 | { 677 | "cell_type": "code", 678 | "execution_count": null, 679 | "id": "ff1e09da", 680 | "metadata": {}, 681 | "outputs": [], 682 | "source": [ 683 | "set.symmetric_difference_update(set)\n", 684 | "# Remove the items that are present in both sets, AND insert the items that is not present in both sets:" 685 | ] 686 | }, 687 | { 688 | "cell_type": "code", 689 | "execution_count": null, 690 | "id": "184e30fc", 691 | "metadata": {}, 692 | "outputs": [], 693 | "source": [] 694 | }, 695 | { 696 | "cell_type": "code", 697 | "execution_count": null, 698 | "id": "37bfcea8", 699 | "metadata": {}, 700 | "outputs": [], 701 | "source": [ 702 | "set.union(set1, set2...)\n", 703 | "# Return a set that contains all items from both sets, duplicates are excluded:" 704 | ] 705 | }, 706 | { 707 | "cell_type": "code", 708 | "execution_count": 41, 709 | "id": "ecee7b18", 710 | "metadata": {}, 711 | "outputs": [ 712 | { 713 | "data": { 714 | "text/plain": [ 715 | "{'c', 'c++', 'geeta', 'java', 'om', 'pooja', 'python', 'ram', 'sham'}" 716 | ] 717 | }, 718 | "execution_count": 41, 719 | "metadata": {}, 720 | "output_type": "execute_result" 721 | } 722 | ], 723 | "source": [ 724 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 725 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\",\"sham\"}\n", 726 | "\n", 727 | "z=x.union(y)\n", 728 | "\n", 729 | "z" 730 | ] 731 | }, 732 | { 733 | "cell_type": "code", 734 | "execution_count": null, 735 | "id": "b7f358a4", 736 | "metadata": {}, 737 | "outputs": [], 738 | "source": [ 739 | "set.update(set)\n", 740 | "# Insert the items from set y into set x:" 741 | ] 742 | }, 743 | { 744 | "cell_type": "code", 745 | "execution_count": 42, 746 | "id": "20cde9c0", 747 | "metadata": {}, 748 | "outputs": [ 749 | { 750 | "data": { 751 | "text/plain": [ 752 | "{'c', 'c++', 'geeta', 'java', 'om', 'pooja', 'python', 'ram', 'sham'}" 753 | ] 754 | }, 755 | "execution_count": 42, 756 | "metadata": {}, 757 | "output_type": "execute_result" 758 | } 759 | ], 760 | "source": [ 761 | "x={\"ram\",\"sham\",\"geeta\",\"pooja\",\"om\"}\n", 762 | "y={\"c\",\"c++\",\"java\",\"python\",\"ram\",\"sham\"}\n", 763 | "\n", 764 | "x.update(y)\n", 765 | "\n", 766 | "x" 767 | ] 768 | }, 769 | { 770 | "cell_type": "markdown", 771 | "id": "d0a99c12", 772 | "metadata": {}, 773 | "source": [ 774 | "# -------------------------------------Page End-------------------------------------\n", 775 | "Asterisc.in \n", 776 | "We will help you bring out the best in you...!! \n", 777 | "Industrial Training / Internship / College Projects\n", 778 | "Contact 7744822228 / 7743822228 \n", 779 | "Branches : Bhande Plot | Tiranga Chowk | Friends Colony" 780 | ] 781 | } 782 | ], 783 | "metadata": { 784 | "kernelspec": { 785 | "display_name": "Python 3 (ipykernel)", 786 | "language": "python", 787 | "name": "python3" 788 | }, 789 | "language_info": { 790 | "codemirror_mode": { 791 | "name": "ipython", 792 | "version": 3 793 | }, 794 | "file_extension": ".py", 795 | "mimetype": "text/x-python", 796 | "name": "python", 797 | "nbconvert_exporter": "python", 798 | "pygments_lexer": "ipython3", 799 | "version": "3.10.3" 800 | } 801 | }, 802 | "nbformat": 4, 803 | "nbformat_minor": 5 804 | } 805 | --------------------------------------------------------------------------------