├── Add two Number.py ├── Arihtmetic Operators.py ├── Create Module ├── __pycache__ │ └── area.cpython-312.pyc ├── area.py └── test class.py ├── Dictionary.py ├── Dictionary ├── Change Value.py ├── Dictionary.py ├── List to convert Dictionary.py ├── Loop.py ├── Nested Dictionary.py ├── Type of file.py └── create Dictionary.py ├── Exam Practice Sir ├── OOP_Concept_Lab_Class.ipynb ├── Shop.py ├── fall2021_1a.py ├── fall2021_2a.py ├── fall2022.py ├── oop_concept_lab_class.py ├── spring2022_1(a).py └── spring2022_1c.py ├── Exception Handlelling.py ├── First Class ├── Calculator.py ├── Clacuator switch case.py ├── main.py └── new file.py ├── First.py ├── Formatted String.py ├── Function Python ├── Argument Pass.py ├── Default parameter Value.py ├── Function.py ├── Recursion.py ├── Unknown Parameter.py └── return Value.py ├── Grantt Chat.py ├── I P E.py ├── Inheritance ,Polymorphism and Encapsulation.py ├── Inheritance Code └── 1.py ├── Inner If Statement.py ├── Lab work 7 (10-02-2024 ) ├── String.py ├── Task 1.py ├── Task 2.py ├── Task 3.py ├── pattern.py ├── series all number addition.py ├── while loop 1.py ├── while loop 2.py └── while loop 3.py ├── Lambda Python ├── Lambda.py └── function lambda.py ├── Lambda.py ├── LeapYear.py ├── Letter Grade Program.py ├── List (Part-1).py ├── List Code ├── List All type of code .py └── number to List convert.py ├── Loop ├── For Loop.py ├── Nasted Loop 1.py └── nested loop.py ├── Number write sequence.py ├── Numerical.py ├── Object ,class ├── A practical example of inheritance.py ├── Basic 1.py ├── Inheritance.py ├── Method Overriding.py ├── Method create.py ├── Multiple Inheritance.py ├── Practice constructore.py └── construictor.py ├── Pattern ├── Pattern 2.py └── Pattern.py ├── Prime number find.py ├── Print Division.py ├── Program file.py ├── Python Class ├── Class.py ├── class 2.py └── self parameter.py ├── Quiz 3 Rifat ├── 1.py └── 2.py ├── Random number guess.py ├── Relational Operator & Boolean Data Type.py ├── Square_root.py ├── Sum of n numbers.py ├── Ternary Operator.py ├── Two number add and print .py ├── Typecasting.py ├── a web scraper.py ├── break and continue.py ├── elements of matrix.py ├── elif statement.py ├── if, else statement.py ├── inheritance.py ├── input.py ├── series ├── series 1.py ├── series 2.py ├── series 3.py └── series 4.py ├── square Root.py └── while loop.py /Add two Number.py: -------------------------------------------------------------------------------- 1 | # Using Return function to print 2 | a = 5 3 | b = 6 4 | 5 | def sum(a,b): 6 | return a+b 7 | 8 | # function call 9 | print(sum(a,b)) 10 | -------------------------------------------------------------------------------- /Arihtmetic Operators.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | a = int(input()) 3 | b = int(input()) 4 | 5 | sum = a + b 6 | division = a - b 7 | multiple = a * b 8 | print(sum) 9 | print(division) 10 | print(multiple) 11 | -------------------------------------------------------------------------------- /Create Module/__pycache__/area.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajjadjim/Basic-Python/327aeaae5a92f26ca7de9c2d9a7b9c4a1a016b42/Create Module/__pycache__/area.cpython-312.pyc -------------------------------------------------------------------------------- /Create Module/area.py: -------------------------------------------------------------------------------- 1 | def tringle(base , height): 2 | area = 0.5 * base * height 3 | print(f"Area of triangle value ->>{area}") 4 | 5 | def RectAnglle( base , height): 6 | Ract_area = base * height 7 | print(f"Area of triangle value ->>{Ract_area}") -------------------------------------------------------------------------------- /Create Module/test class.py: -------------------------------------------------------------------------------- 1 | from area import RectAnglle , tringle 2 | 3 | tringle(5,5) 4 | 5 | RectAnglle(5,5) -------------------------------------------------------------------------------- /Dictionary.py: -------------------------------------------------------------------------------- 1 | thisdict = { 2 | "brand": "Ford", 3 | "model": "Mustang", 4 | "year": 1964 5 | } 6 | print(thisdict) 7 | 8 | 9 | thisdict = { 10 | "brand": "Ford", 11 | "model": "Mustang", 12 | "year": 1964 13 | } 14 | print(thisdict["brand"]) 15 | 16 | 17 | thisdict = { 18 | "brand": "Ford", 19 | "model": "Mustang", 20 | "year": 1964, 21 | "year": 2020 22 | } 23 | print(thisdict) 24 | 25 | 26 | thisdict = { 27 | "brand": "Ford", 28 | "model": "Mustang", 29 | "year": 1964, 30 | "year": 2020 31 | } 32 | print(len(thisdict)) 33 | 34 | 35 | thisdict = dict(name = "John", age = 36, country = "Norway") 36 | print(thisdict) 37 | 38 | -------------------------------------------------------------------------------- /Dictionary/Change Value.py: -------------------------------------------------------------------------------- 1 | my_dict = { 2 | "brand": "Ford", 3 | "model": "Mustang", 4 | "year": 1964 5 | } 6 | my_dict[("year")] = 2018 7 | print(my_dict) 8 | 9 | ######### Another Method use 10 | 11 | my_dict.update({"year" : 2020}) 12 | print(my_dict) 13 | 14 | 15 | print("\n \n") 16 | 17 | #################### Python - Add Dictionary Items 18 | my_dict1 = { 19 | "brand": "Ford", 20 | "model": "Mustang", 21 | "year": 1964 22 | } 23 | my_dict1[("color")] = "Red" 24 | print(my_dict1) 25 | 26 | ########## Another Process 27 | my_dict1.update({"color" : "Yeolow"}) 28 | print(my_dict1) 29 | 30 | print("\n") 31 | ############## Pop Item any 32 | thisdict = { 33 | "brand": "Ford", 34 | "model": "Mustang", 35 | "year": 1964 36 | } 37 | thisdict.pop("model") 38 | print(thisdict) 39 | 40 | thisdict.popitem() 41 | print(thisdict) 42 | 43 | ######### Index Pop 44 | thisdict.popitem() 45 | print(thisdict) 46 | -------------------------------------------------------------------------------- /Dictionary/Dictionary.py: -------------------------------------------------------------------------------- 1 | ########################################### Dictionary Function Using ####################### 2 | person = {'name': 'Jim', 'age': 30, 'city': 'Dhaka'} 3 | 4 | 5 | ########################## Key Print the ############################################################ 6 | for value in person.keys(): 7 | print(f"Print only value : {value}") 8 | 9 | ######### Update Value ######## 10 | person.update({'name':'XYZ'}) 11 | person['age']= 25 12 | 13 | 14 | ############## Update Value ############ 15 | person.update({'gender' :'Male'}) 16 | person['gender'] = 'Male' 17 | 18 | ############ Print Dictionary items ##################### 19 | for value in person.items(): 20 | print(value) 21 | 22 | ############################### Specific Key & Item Print the value ################################# 23 | thisdict = { 24 | "brand": "Ford", 25 | "model": "Mustang", 26 | "year": 1964 27 | } 28 | for key, item in thisdict.items(): 29 | print(key, item) 30 | -------------------------------------------------------------------------------- /Dictionary/List to convert Dictionary.py: -------------------------------------------------------------------------------- 1 | my_list=[("jim",101) ,("Rifat" ,102) , ("mahfuj",103)] 2 | 3 | my_dict =dict(my_list) 4 | print(my_dict) 5 | 6 | ################ Another Default Program 7 | create_List =["Jim" , "Rifat" , "Mahfuj" , "Tahid"] 8 | convert_dict ={key : value for key , value in enumerate(create_List)} 9 | print(convert_dict) 10 | -------------------------------------------------------------------------------- /Dictionary/Loop.py: -------------------------------------------------------------------------------- 1 | my_dictionary = { 2 | "name" : "JIM", 3 | "age" : 24, 4 | "District" : "Manikjong" 5 | } 6 | ######### Both Value nad key print Dictionary 7 | for x , y in my_dictionary.items(): 8 | print(f"Key ->{x}, value ->{y}") 9 | 10 | ##### Value Print Only 11 | for y in my_dictionary.values(): 12 | print(y) 13 | ########### Key Print Only 14 | for x in my_dictionary.keys(): 15 | print(x) 16 | 17 | 18 | ############## Copy the Dictionary Values 19 | copy_dict = my_dictionary.copy() 20 | print(copy_dict) 21 | -------------------------------------------------------------------------------- /Dictionary/Nested Dictionary.py: -------------------------------------------------------------------------------- 1 | child1 = { 2 | "name" : "sajjad Jim", 3 | "year" : 1999 4 | } 5 | child2 = { 6 | "name" : "XYZ", 7 | "year" : 2001 8 | } 9 | child3 = { 10 | "name" : "ABCD", 11 | "year" : 2011 12 | } 13 | 14 | myfamily = { 15 | "myself1" : child1, 16 | "myself2" : child2, 17 | "myself3" : child3 18 | } 19 | print(f"Nested Dictionary print -> {myfamily}") 20 | 21 | ############################################################## 22 | myfamily = { 23 | "child1" : { 24 | "name" : "Sajjad", 25 | "year" : 2004 26 | }, 27 | "child2" : { 28 | "name" : "Hossain", 29 | "year" : 2007 30 | }, 31 | "child3" : { 32 | "name" : "Jim", 33 | "year" : 2011 34 | } 35 | } 36 | print(F"Print my name ->{myfamily["child2"]["name"]}") 37 | -------------------------------------------------------------------------------- /Dictionary/Type of file.py: -------------------------------------------------------------------------------- 1 | thisdict = { 2 | "brand": "Jim", 3 | "model": "samsung", 4 | "year": 1999 5 | } 6 | print(type(thisdict)) 7 | -------------------------------------------------------------------------------- /Dictionary/create Dictionary.py: -------------------------------------------------------------------------------- 1 | create_dictiorany = dict(name = "JIM" , age = 26 , District = "Manikgonj") 2 | print(create_dictiorany) 3 | -------------------------------------------------------------------------------- /Exam Practice Sir/OOP_Concept_Lab_Class.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [] 7 | }, 8 | "kernelspec": { 9 | "name": "python3", 10 | "display_name": "Python 3" 11 | }, 12 | "language_info": { 13 | "name": "python" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "code", 19 | "execution_count": 12, 20 | "metadata": { 21 | "colab": { 22 | "base_uri": "https://localhost:8080/" 23 | }, 24 | "id": "1hdIqunxNcdG", 25 | "outputId": "5da7b0b0-56c9-4c85-dc63-ed4dda88c5b0" 26 | }, 27 | "outputs": [ 28 | { 29 | "output_type": "stream", 30 | "name": "stdout", 31 | "text": [ 32 | "Mohammed Shahabuddin\n", 33 | "CSE department information is sucessfully inserted\n", 34 | "Method is not overridden\n", 35 | "Hi 221-15-4997, Your registration will be done by dept or advisor\n", 36 | "Hi 221-15-4998, Your registration is successfull \n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "#Inheritance #Polymorphism #Encapsulation\n", 42 | "class University:\n", 43 | " chancellor=\"Mohammed Shahabuddin\"\n", 44 | "\n", 45 | " def set_info(self,univ_name,univ_location,univ_type,univ_vc_name):\n", 46 | " self.univ_name= univ_name #Public Attribute\n", 47 | " self._univ_location= univ_location #Protected Atribute\n", 48 | " self.__univ_type= univ_type #Private Attribute\n", 49 | " self.univ_vc_name= univ_vc_name\n", 50 | "\n", 51 | " def get_info(self):\n", 52 | " print(f\"University Name:{self.univ_name} \\n University Location: {self.univ_location}\")\n", 53 | "\n", 54 | "\n", 55 | "\n", 56 | "class Department(University):\n", 57 | " def __init__(self, dept_id, dept_name, dept_head):\n", 58 | " self.dept_id=dept_id\n", 59 | " self.dept_name=dept_name\n", 60 | " self.dept_head=dept_head\n", 61 | " print(f\"{dept_name} department information is sucessfully inserted\")\n", 62 | "\n", 63 | " def viewCampus(self):\n", 64 | " print(\"Method is not overridden\")\n", 65 | "\n", 66 | "\n", 67 | "\n", 68 | " def registration_req(self,student_id,dept,term, delay):\n", 69 | " self.student_id=student_id\n", 70 | " if (delay==True):\n", 71 | " print(f\"Hi {student_id}, Your registration is successfull \")\n", 72 | "\n", 73 | " else:\n", 74 | " print(f\"Hi {student_id}, Your registration will be done by dept or advisor\")\n", 75 | "\n", 76 | "\n", 77 | "\n", 78 | "\n", 79 | "#University Class\n", 80 | "obj1=University()\n", 81 | "print(obj1.chancellor)\n", 82 | "\n", 83 | "\n", 84 | "#Department Class\n", 85 | "\n", 86 | "obj2=Department(\"15\",\"CSE\", \"SRHN\")\n", 87 | "obj2.viewCampus()\n", 88 | "obj2.registration_req(\"221-15-4997\", \"CSE\", \"Fall 2024\",False)\n", 89 | "obj2.registration_req(\"221-15-4998\", \"CSE\", \"Fall 2024\",True)\n", 90 | "\n", 91 | "\n", 92 | "\n", 93 | "\n", 94 | "\n" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "source": [ 100 | "from logging import NullHandler\n", 101 | "def divide(x,y):\n", 102 | " try: # Always Execute\n", 103 | " result=x/y # x=10, y=2\n", 104 | " print(result)\n", 105 | " except: # Alternate of try\n", 106 | " print(\"Error in try block\")\n", 107 | " finally:\n", 108 | " print(\"End of division\")\n", 109 | "\n", 110 | "divide(10,2)\n", 111 | "divide(10,0)\n" 112 | ], 113 | "metadata": { 114 | "colab": { 115 | "base_uri": "https://localhost:8080/" 116 | }, 117 | "id": "vmDP2lHKYXQH", 118 | "outputId": "ec97c90e-5244-4e14-fc96-1094fdfd192d" 119 | }, 120 | "execution_count": 18, 121 | "outputs": [ 122 | { 123 | "output_type": "stream", 124 | "name": "stdout", 125 | "text": [ 126 | "5.0\n", 127 | "End of division\n", 128 | "Error in try block\n", 129 | "End of division\n" 130 | ] 131 | } 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "source": [], 137 | "metadata": { 138 | "id": "XDzDLa-8Wxtf" 139 | }, 140 | "execution_count": null, 141 | "outputs": [] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "source": [], 146 | "metadata": { 147 | "id": "xdFmjgZ4aw7J" 148 | }, 149 | "execution_count": 16, 150 | "outputs": [] 151 | } 152 | ] 153 | } -------------------------------------------------------------------------------- /Exam Practice Sir/Shop.py: -------------------------------------------------------------------------------- 1 | class Shop: 2 | Shop_Name ="\t\tHungry Bite" 3 | 4 | def set_info(self, shop_address , shop_owner): 5 | self.shop_address = shop_address 6 | self.shop_owner = shop_owner 7 | 8 | def get_info(self): 9 | print(f"Shop Address-> {self.shop_address}\nShop owner Name->{self.shop_owner}\n") 10 | 11 | class purchase_product(Shop): 12 | def __init__(self , customer_name ,customer_food , customer_bill , confirm_order): 13 | self.customer_name = customer_name 14 | self.customer_food = customer_food 15 | self.customer_bill =customer_bill 16 | self.confirm_order = confirm_order 17 | 18 | print(f"Customer Name --{customer_name}\n Customer Food --{customer_food} \nCustomer Bill ---{customer_bill}") 19 | 20 | print(f"Customer Food Order {confirm_order} ") 21 | 22 | def view_shop(self): 23 | print(f"Welcome to our Shop !!!") 24 | 25 | obj1 =Shop() 26 | print(obj1.Shop_Name) 27 | obj1=Shop() 28 | obj1.set_info("Ashula Vanggar potti","Sobur Khan") 29 | obj1.get_info() 30 | 31 | obj1.Shop_Name 32 | obj2 =purchase_product("ABCD", "Burger" ,300,"Confirm") 33 | obj3 =purchase_product("XYZ", "Sub-Sanduse---" ,350,"Confirm") 34 | -------------------------------------------------------------------------------- /Exam Practice Sir/fall2021_1a.py: -------------------------------------------------------------------------------- 1 | class StudentManagement: 2 | def __init__(self): 3 | self.students = {} 4 | 5 | def accept(self, name, roll, marks1, marks2): 6 | self.students[roll] = [name, roll, marks1, marks2] 7 | 8 | def display(self): 9 | print("Student Details:") 10 | for roll, values in self.students.items(): 11 | print(f"Student roll: {values[1]}") 12 | print(f"Student name: {values[0]}") 13 | print(f"Mark1: {values[2]}") 14 | print(f"Mark2: {values[3]}") 15 | 16 | def search(self, roll): 17 | if roll in self.students: 18 | values = self.students[roll] 19 | print(f"Student roll: {values[1]}") 20 | print(f"Student name: {values[0]}") 21 | print(f"Mark1: {values[2]}") 22 | print(f"Mark2: {values[3]}") 23 | else: 24 | print(f"Student with roll number {roll} not found.") 25 | 26 | 27 | st = StudentManagement() 28 | 29 | st.accept("Rahim", 1, 70, 80) 30 | st.accept("Fahim", 2, 78, 60) 31 | st.accept("Mahim", 3, 66, 83) 32 | st.accept("Zahim", 4, 71, 86) 33 | st.accept("Tahim", 5, 77, 92) 34 | 35 | st.display() 36 | 37 | st.search(4) 38 | st.search(6) -------------------------------------------------------------------------------- /Exam Practice Sir/fall2021_2a.py: -------------------------------------------------------------------------------- 1 | class Time: 2 | def __init__(self,hr,min): 3 | self.hr=hr 4 | self.min=min 5 | 6 | def addTime(self,time2): 7 | total=self.hr*60+time2.hr*60+time2.min+self.min 8 | hr=total//60 9 | min=total%60 10 | return Time(hr,min) 11 | 12 | def displayTime(self): 13 | print(f"Time: {self.hr}hours and {self.min} minutes") 14 | 15 | def timemin(self): 16 | print(f"Time in minutes: {self.hr*60+self.min} minutes") 17 | 18 | t1=Time(3,45) 19 | t2=Time(5,30) 20 | 21 | t1.displayTime() 22 | t1.timemin() 23 | 24 | t2.displayTime() 25 | t2.timemin() 26 | 27 | newtime=t1.addTime(t2) 28 | newtime.displayTime() 29 | newtime.timemin() 30 | -------------------------------------------------------------------------------- /Exam Practice Sir/fall2022.py: -------------------------------------------------------------------------------- 1 | class StarBuck: 2 | coffee={ 3 | 'latte':100, 4 | 'black':70, 5 | 'regular':80, 6 | 'americano':120, 7 | 'cappuccino':150, 8 | 'espresso':100, 9 | } 10 | 11 | def __init__(self): 12 | self.order1='' 13 | self.quantity1=0 14 | self.order2='' 15 | self.quantity2=0 16 | self.order3='' 17 | self.quantity3=0 18 | self.ratings=0 19 | 20 | 21 | def details(self,order1,quantity1,order2,quantity2,order3,quantity3): 22 | self.order1=order1 23 | self.quantity1=quantity1 24 | self.order2=order2 25 | self.quantity2=quantity2 26 | self.order3=order3 27 | self.quantity3=quantity3 28 | self.total=self.quantity1*self.coffee[order1]+self.quantity2*self.coffee[order2]+self.quantity3*self.coffee[order3] 29 | self.orders={} 30 | self.orders.update({order1:self.coffee[order1]}) 31 | self.orders.update({order2:self.coffee[order2]}) 32 | self.orders.update({order3:self.coffee[order3]}) 33 | final=sorted(self.orders.items(),key=lambda x:x[1]) 34 | print(f"Your orders are ") 35 | for key in final: 36 | print(f"{key}") 37 | print(f"Your total is {self.total}") 38 | 39 | 40 | def deliver(self): 41 | print(f"Your order will be delivered in 30 minutes") 42 | 43 | def rating(self,ratings): 44 | self.ratings=ratings 45 | print(f"Customer gave a {self.ratings}") 46 | 47 | 48 | 49 | 50 | 51 | customer=StarBuck() 52 | print("The Menus: Latte:100,black:70,regular:80,americano:120,cappuccino:150,espresso:100,") 53 | print("<---Please enter your choice and quantity--->") 54 | order1=input("Please Enter the coffee Name:") 55 | quantity1=int(input("Please Enter the Quantity:")) 56 | order2=input("Please Enter the coffee Name:") 57 | quantity2=int(input("Please Enter the quantity:")) 58 | 59 | 60 | # customer.details('latte',2,'black',1,'regular',3) 61 | customer.details(order1,quantity1,order2,quantity2) 62 | customer.deliver() 63 | 64 | rat=int(input("Please give a rating from 1 to 5:")) 65 | customer.rating(rat) -------------------------------------------------------------------------------- /Exam Practice Sir/oop_concept_lab_class.py: -------------------------------------------------------------------------------- 1 | #Inheritance #Polymorphism #Encapsulation 2 | class University: 3 | chancellor="Mohammed Shahabuddin" 4 | 5 | def set_info(self,univ_name,univ_location,univ_type,univ_vc_name): 6 | self.univ_name= univ_name #Public Attribute 7 | self._univ_location= univ_location #Protected Atribute 8 | self.__univ_type= univ_type #Private Attribute 9 | self.univ_vc_name= univ_vc_name 10 | 11 | def get_info(self): 12 | print(f"University Name:{self.univ_name} \n University Location: {self.univ_location}") 13 | 14 | 15 | class Department(University): 16 | def __init__(self, dept_id, dept_name, dept_head): 17 | self.dept_id=dept_id 18 | self.dept_name=dept_name 19 | self.dept_head=dept_head 20 | print(f"{dept_name} department information is sucessfully inserted") 21 | 22 | def viewCampus(self): 23 | #print("\nOur Campus is Very Fucking Good..........") 24 | print("Method is not overridden\n") 25 | 26 | 27 | 28 | def registration_req(self,student_id,dept,term, delay): 29 | self.student_id=student_id 30 | if (delay==True): 31 | print(f"Hi {student_id}, Your registration is successfull ") 32 | 33 | else: 34 | print(f"Hi {student_id}, Your registration will be done by dept or advisor") 35 | 36 | 37 | #University Class 38 | obj1=University() 39 | print(obj1.chancellor) 40 | 41 | 42 | #Department Class 43 | obj2=Department("15","CSE", "SRHN") 44 | obj2.viewCampus() 45 | obj2.registration_req("221-15-4997", "CSE", "Fall 2024",False) 46 | obj2.registration_req("221-15-4998", "CSE", "Fall 2024",True) 47 | 48 | from logging import NullHandler 49 | 50 | """def divide(x,y): 51 | try: # Always Execute 52 | result=x/y # x=10, y=2 53 | print(result) 54 | except: # Alternate of try 55 | print("Error in try block") 56 | finally: 57 | print("End of division") 58 | 59 | divide(10,2) 60 | divide(10,0)""" 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Exam Practice Sir/spring2022_1(a).py: -------------------------------------------------------------------------------- 1 | class BankUser: 2 | def __init__(self): 3 | self.balance=0 4 | self.name="" 5 | 6 | def user_details(self,name): 7 | self.name=name 8 | print(f"User name: {self.name}") 9 | print(f"Balance: {self.balance}") 10 | 11 | def deposit(self,amount): 12 | self.balance=self.balance+amount 13 | print(f"Amount deposited: {amount}") 14 | print(f"Balance: {self.balance}") 15 | 16 | def withdraw(self,amount): 17 | if self.balance>=amount: 18 | self.balance=self.balance-amount 19 | print(f"Amount withdrawn: {amount}") 20 | print(f"Balance: {self.balance}") 21 | else: 22 | print("Insufficient balance") 23 | 24 | user=BankUser() 25 | 26 | user.user_details("Rahul") 27 | 28 | user.deposit(1000) 29 | user.withdraw(500) -------------------------------------------------------------------------------- /Exam Practice Sir/spring2022_1c.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | def __init__(self,name,email): 3 | self.name=name 4 | self.email=email 5 | self.salary=0 6 | 7 | 8 | def employee_details(self): 9 | print(f"Employee name: {self.name}") 10 | print(f"Employee email: {self.email}") 11 | print(f"Employee salary: {self.salary}") 12 | 13 | def check_in(self): 14 | print("Employee is checked in at 9 am") 15 | 16 | def check_out(self): 17 | print("Employee is checked out at 5 pm") 18 | 19 | class Faculty(Employee): 20 | def __init__(self,name,email): 21 | super().__init__(name,email) 22 | self.salary=30000 23 | 24 | def conduct_class(self): 25 | print(f"{self.name} is conducting class") 26 | 27 | def couselling_student(self): 28 | print(f"{self.name} is couselling student") 29 | 30 | def salary_details(self): 31 | print(f"{self.name}'s previous salary: {self.salary}") 32 | print(f"{self.name}'s new salary: {self.salary + 0.1*self.salary}") 33 | 34 | 35 | 36 | #(iii) ans: new checkin checkout for faculty 37 | def check_in(self): 38 | print("Faculty is checked in at 9:30 am") 39 | 40 | def check_out(self): 41 | print("Faculty is checked out at 5:30 pm") 42 | 43 | class Admin(Employee): 44 | def __init__(self,name,email): 45 | super().__init__(name,email) 46 | self.salary=35000 47 | 48 | def management_campus(self): 49 | print(f"{self.name} is managing campus") 50 | 51 | def monitor_student(self): 52 | print(f"{self.name} is monitoring student") 53 | 54 | def salary_details(self): 55 | print(f"{self.name}'s previous salary: {self.salary}") 56 | print(f"{self.name}'s new salary: {self.salary + 0.15*self.salary}") 57 | 58 | 59 | #(iii) ans: new checkin checkout for admin 60 | def check_in(self): 61 | print("Admin is checked in at 8 am") 62 | 63 | def check_out(self): 64 | print("Admin is checked out at 6 pm") 65 | 66 | 67 | roshna=Faculty("Roshna","roshna@gmail.com") 68 | roshna.employee_details() 69 | roshna.check_in() 70 | roshna.check_out() 71 | roshna.conduct_class() 72 | roshna.couselling_student() 73 | roshna.salary_details() 74 | 75 | rahim=Admin("Rahim","rahim@gmail.com") 76 | 77 | rahim.employee_details() 78 | rahim.check_in() 79 | rahim.check_out() 80 | rahim.management_campus() 81 | rahim.monitor_student() 82 | rahim.salary_details() 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Exception Handlelling.py: -------------------------------------------------------------------------------- 1 | from logging import NullHandler 2 | def divide(x,y): 3 | try: # Always Execute 4 | result=x/y # x=10, y=2 5 | print(result) 6 | except: # Alternate of try 7 | print("Error in try block") 8 | finally: 9 | print("End of division") 10 | 11 | divide(10,2). 12 | divide(10,0) 13 | -------------------------------------------------------------------------------- /First Class/Calculator.py: -------------------------------------------------------------------------------- 1 | oparator = input("Choice an operator (+, -, *, /): ") 2 | 3 | first = float(input("Enter the first number: ")) 4 | second = float(input("Enter the second number: ")) 5 | 6 | if oparator == '+': 7 | result1 = first+second 8 | print(f"{first} + {second} = {result1}") 9 | elif oparator == '-': 10 | result2 = first-second 11 | print(f"{first} - {second} = {result2}") 12 | elif oparator == '*': 13 | result3 = first*second 14 | print(f"{first} * {second} = {result3}") 15 | elif oparator == '/': 16 | result4 = first / second 17 | print(f"{first} / {second} = {result4}") 18 | else: 19 | print("Error! Operator is not correct.") 20 | -------------------------------------------------------------------------------- /First Class/Clacuator switch case.py: -------------------------------------------------------------------------------- 1 | oparator = input('Enter The oparator here :') 2 | numbers = list(map(int, input().split())) 3 | 4 | match oparator: 5 | case '+': 6 | print(sum(numbers)) 7 | case '-': 8 | temp = numbers[0] 9 | 10 | for x in range(1, len(numbers)): 11 | temp = temp - numbers[x] 12 | print(temp) 13 | 14 | case '*': 15 | temp = numbers[0] 16 | 17 | for x in range(1, len(numbers)): 18 | temp = temp * numbers[x] 19 | print(temp) 20 | case '/': 21 | temp = numbers[0] 22 | 23 | for x in range(1, len(numbers)): 24 | temp = temp / numbers[x] 25 | print(temp) -------------------------------------------------------------------------------- /First Class/main.py: -------------------------------------------------------------------------------- 1 | """print("Hellow Student!")""" 2 | #My name is Sajjad Jim 3 | x = 8 4 | y = "Daffodil International University" 5 | z = 10.5 6 | is_student=False 7 | print(x) 8 | print(y) 9 | print(z) 10 | print(is_student) 11 | 12 | name ="Sajjad Hossain Jim" 13 | age = 24 14 | university="DIU" 15 | 16 | print("My name is "+name) 17 | print("Your age is"+str(age)) -------------------------------------------------------------------------------- /First Class/new file.py: -------------------------------------------------------------------------------- 1 | x = 11 2 | y = 22 3 | z = 33 4 | 5 | sum = x + y + z 6 | 7 | print("Value =",sum) 8 | print("Sum of 3 digit number "+str(sum)) 9 | 10 | x =input("Please enter your name :") 11 | print("Your name is :",x) 12 | 13 | -------------------------------------------------------------------------------- /First.py: -------------------------------------------------------------------------------- 1 | print("Hellow World... !") 2 | 3 | print("My first programming python course....") 4 | 5 | print("print(My first programming python course)") 6 | 7 | print("My name is Sajjad Hossain jim.......") 8 | print("JIM "+" Helow world ......") 9 | print("My home dristrict Manikgonj.....") 10 | -------------------------------------------------------------------------------- /Formatted String.py: -------------------------------------------------------------------------------- 1 | num1 = 10 2 | num2 = 11 3 | print("sum is ",num1 + num2) 4 | 5 | print(f"{num1} + {num2} = {num1+num2}") 6 | 7 | print("Sajjad Hossain Jim..",end=" ") 8 | print("016****18**") 9 | print("Helow worl!") 10 | -------------------------------------------------------------------------------- /Function Python/Argument Pass.py: -------------------------------------------------------------------------------- 1 | def my_function(sname , xname): 2 | print(sname,"are both good",xname) 3 | 4 | my_function("Jim","Siam") 5 | 6 | my_function("Email") -------------------------------------------------------------------------------- /Function Python/Default parameter Value.py: -------------------------------------------------------------------------------- 1 | def my_function(country ="Bangladesh"): 2 | print("My country name is " +country) 3 | 4 | my_function("USA") 5 | my_function() 6 | my_function("Australia") 7 | my_function("India") 8 | 9 | 10 | 11 | #Passing List is An Argumment 12 | 13 | def my_functions(food): 14 | for i in food: 15 | print(i) 16 | 17 | fruits = ["Mango" , "Banana" , "Pineapple"] 18 | 19 | my_functions(fruits) 20 | 21 | def count(Value): 22 | for x in Value: 23 | print(x ,end=' ') 24 | 25 | number =[1,2,3,4,5,6,7,8] 26 | count(number) 27 | -------------------------------------------------------------------------------- /Function Python/Function.py: -------------------------------------------------------------------------------- 1 | def my_functions(): 2 | print("My name is Jim") 3 | 4 | 5 | print("Hellow Guys!!",my_functions()) 6 | 7 | my_functions() 8 | 9 | 10 | def my_function(fname): 11 | print(fname +" Human !!") 12 | 13 | my_function("Jim") 14 | my_function("Labonno") 15 | my_function("Siam") -------------------------------------------------------------------------------- /Function Python/Recursion.py: -------------------------------------------------------------------------------- 1 | # 1 + (First+2) + (Second+3)..... [(Last -1)+n] 2 | def tri_recurtion( k ): 3 | if (k > 0) : 4 | result = k + tri_recurtion(k -1) 5 | print(result ,end =' ') 6 | else : 7 | result = 0 8 | return result 9 | 10 | value = int(input("Enter your Value :")) 11 | print("The recurtion example result:") 12 | tri_recurtion(value) 13 | -------------------------------------------------------------------------------- /Function Python/Unknown Parameter.py: -------------------------------------------------------------------------------- 1 | def my_function(*kids): #Multiple Types of kist Given * using 2 | print("The oldest Person is " + kids[0]) # Define the number of serial which i want ot print 3 | 4 | my_function("JIM", "Sajjad" , "Hossain") 5 | 6 | 7 | def my_function(child3, child2, child1): 8 | print("The youngest child is " + child3) 9 | my_function(child1 = "Kubra", child2 = "Siam", child3 = "Jim") 10 | 11 | 12 | def my_functions(**fruits): 13 | print("\n\nThe most tested fruites is " +fruits["num1"]) 14 | print("The most expensive fruits is " +fruits["num2"]) 15 | 16 | my_functions(num1 ="Mango" , num2="BlackBerry" , num3 ="Jackfruits") -------------------------------------------------------------------------------- /Function Python/return Value.py: -------------------------------------------------------------------------------- 1 | def my_function(num): 2 | return 5 * num 3 | 4 | print(my_function(3)) 5 | print(my_function(5)) 6 | print(my_function(9)) 7 | 8 | 9 | def my_function(x, /): 10 | print(x) 11 | 12 | my_function(3) 13 | 14 | #Without the , / you are actually allowed to use keyword arguments even if the function expects positional arguments: 15 | def my_function(x): 16 | print(x) 17 | my_function(x = 3) 18 | 19 | def my_function(a, b, /, *, c, d): 20 | print(a + b + c + d) 21 | 22 | my_function(5, 6, c = 7, d = 8) 23 | -------------------------------------------------------------------------------- /Grantt Chat.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import matplotlib.pyplot as plt 3 | import matplotlib.dates as mdates 4 | 5 | # Define the data 6 | data = { 7 | "Task": [ 8 | "Planning and Requirements", 9 | "Design", 10 | "Development", 11 | "Testing", 12 | "Deployment and Rollout", 13 | "Maintenance and Support" 14 | ], 15 | "Start Time": [ 16 | "2024-06-01", 17 | "2024-06-20", 18 | "2024-07-13", 19 | "2024-09-13", 20 | "2024-10-13", 21 | "2024-11-02" 22 | ], 23 | "End Time": [ 24 | "2024-06-18", 25 | "2024-07-13", 26 | "2024-09-09", 27 | "2024-10-13", 28 | "2024-11-04", 29 | "2024-12-12" 30 | ] 31 | } 32 | 33 | # Create a DataFrame 34 | df = pd.DataFrame(data) 35 | 36 | # Convert Start Time and End Time to datetime 37 | df["Start Time"] = pd.to_datetime(df["Start Time"]) 38 | df["End Time"] = pd.to_datetime(df["End Time"]) 39 | 40 | # Calculate the duration in days 41 | df["Duration"] = (df["End Time"] - df["Start Time"]).dt.days 42 | 43 | # Create the plot 44 | fig, ax = plt.subplots(figsize=(10, 6)) 45 | 46 | # Create a color list for tasks 47 | colors = plt.cm.Paired(range(len(df))) 48 | 49 | # Add the tasks to the Gantt chart 50 | for i, task in enumerate(df.itertuples()): 51 | ax.barh(task.Task, task.Duration, left=task._2, color=colors[i]) 52 | ax.text(task._2 + pd.Timedelta(days=task.Duration / 2), i, f"{task.Duration} days", 53 | va='center', ha='center', color='white', fontweight='bold') 54 | 55 | # Format the x-axis 56 | ax.xaxis_date() 57 | ax.xaxis.set_major_locator(mdates.MonthLocator()) 58 | ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d')) 59 | plt.xticks(rotation=45) 60 | 61 | # Set labels and title 62 | ax.set_xlabel('Date') 63 | ax.set_ylabel('Task') 64 | ax.set_title('Project Schedule Gantt Chart') 65 | 66 | plt.tight_layout() 67 | plt.show() 68 | -------------------------------------------------------------------------------- /I P E.py: -------------------------------------------------------------------------------- 1 | #Inheritance #Polymorphism #Encapsulation 2 | class University: 3 | chancellor="Mohammed Shahabuddin" 4 | 5 | def set_info(self,univ_name,univ_location,univ_type,univ_vc_name): 6 | self.univ_name= univ_name #Public Attribute 7 | self._univ_location= univ_location #Protected Atribute 8 | self.__univ_type= univ_type #Private Attribute 9 | self.univ_vc_name= univ_vc_name 10 | 11 | def get_info(self): 12 | print(f"University Name:{self.univ_name} \n University Location: {self.univ_location}") 13 | 14 | 15 | 16 | class Department(University): 17 | def __init__(self, dept_id, dept_name, dept_head): 18 | self.dept_id=dept_id 19 | self.dept_name=dept_name 20 | self.dept_head=dept_head 21 | print(f"{dept_name} department information is sucessfully inserted") 22 | 23 | def viewCampus(self): 24 | print("Method is not overridden") 25 | 26 | 27 | 28 | def registration_req(self,student_id,dept,term, delay): 29 | self.student_id=student_id 30 | if (delay==True): 31 | print(f"Hi {student_id}, Your registration is successfull ") 32 | 33 | else: 34 | print(f"Hi {student_id}, Your registration will be done by dept or advisor") 35 | 36 | 37 | 38 | 39 | #University Class 40 | obj1=University() 41 | print(obj1.chancellor) 42 | 43 | 44 | #Department Class 45 | 46 | obj2=Department("15","CSE", "SRHN") 47 | obj2.viewCampus() 48 | obj2.registration_req("221-15-4997", "CSE", "Fall 2024",False) 49 | obj2.registration_req("221-15-4998", "CSE", "Fall 2024",True) 50 | 51 | from logging import NullHandler 52 | def divide(x,y): 53 | try: # Always Execute 54 | result=x/y # x=10, y=2 55 | print(result) 56 | except: # Alternate of try 57 | print("Error in try block") 58 | finally: 59 | print("End of division") 60 | 61 | divide(10,2) 62 | divide(10,0) 63 | -------------------------------------------------------------------------------- /Inheritance ,Polymorphism and Encapsulation.py: -------------------------------------------------------------------------------- 1 | #Inheritance 2 | #Polymorphism 3 | #Encapsulation 4 | 5 | class University: 6 | chancellor="Mohammed Shahabuddin" 7 | 8 | def set_info(self,univ_name,univ_location,univ_type,univ_vc_name): 9 | self.univ_name= univ_name #Public Attribute 10 | self._univ_location= univ_location #Protected Atribute 11 | self.__univ_type= univ_type #Private Attribute 12 | self.univ_vc_name= univ_vc_name 13 | 14 | def get_info(self): 15 | print(f"University Name:{self.univ_name} \n University Location: {self.univ_location}") 16 | 17 | 18 | 19 | class Department(University): 20 | def __init__(self, dept_id, dept_name, dept_head): 21 | self.dept_id=dept_id 22 | self.dept_name=dept_name 23 | self.dept_head=dept_head 24 | print(f"{dept_name} department information is sucessfully inserted") 25 | 26 | def viewCampus(self): 27 | print("Method is not overridden") 28 | 29 | 30 | 31 | def registration_req(self,student_id,dept,term, delay): 32 | self.student_id=student_id 33 | if (delay==True): 34 | print(f"Hi {student_id}, Your registration is successfull ") 35 | 36 | else: 37 | print(f"Hi {student_id}, Your registration will be done by dept or advisor") 38 | 39 | 40 | 41 | 42 | #University Class 43 | obj1=University() 44 | print(obj1.chancellor) 45 | 46 | 47 | #Department Class 48 | 49 | obj2=Department("15","CSE", "SRHN") 50 | obj2.viewCampus() 51 | obj2.registration_req("221-15-4997", "CSE", "Fall 2024",False) 52 | obj2.registration_req("221-15-4998", "CSE", "Fall 2024",True) 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Inheritance Code/1.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, fname, lname): 3 | self.firstname = fname 4 | self.lastname = lname 5 | 6 | def printname(self): 7 | print(self.firstname, self.lastname) 8 | 9 | #Use the Person class to create an object, and then execute the printname method: 10 | 11 | y = Person("Jim" ,"King") 12 | x = Person("Sajjad Hossain", "Jim") 13 | x.printname() 14 | y.printname() -------------------------------------------------------------------------------- /Inner If Statement.py: -------------------------------------------------------------------------------- 1 | num = 5 2 | if num > 4: 3 | if num > 2: 4 | print("My name is Jim") 5 | 6 | #Largest Number find 3 number 7 | num1 = 12 8 | num2 =15 9 | num3 = 13 10 | if num1 >num2: 11 | if num1>num3: 12 | print(num1) 13 | if num2>num1: 14 | if num2>num3: 15 | print(num2) 16 | if num3>num1: 17 | if num3>num2: 18 | print(num3) 19 | -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/String.py: -------------------------------------------------------------------------------- 1 | my_string = "S. M. SAJJAD HOSSAIN JIM !!" 2 | 3 | print("Original string:", my_string) 4 | 5 | print("First character:", my_string[0]) 6 | print("Last character:", my_string[-1]) 7 | 8 | # Slicing the string 9 | print("Substring from index 7 to the last:", my_string[7:]) 10 | print("Substring from index 7 to 12:", my_string[7:12]) 11 | 12 | # Concatenate strings 13 | new_string = my_string + " Welcome!" 14 | print("Concatenated string:", new_string) 15 | 16 | # Length of the string 17 | print("Length of the string:", len(my_string)) 18 | 19 | # Convert the string to uppercase and lowercase 20 | print("Uppercase:", my_string.upper()) 21 | print("Lowercase:", my_string.lower()) 22 | 23 | # Replace a substring 24 | replaced_string = my_string.replace("world", "Python") 25 | print("String after replacement:", replaced_string) 26 | 27 | # Split the string into a list of substrings 28 | split_string = my_string.split(",") 29 | print("Split string:", split_string) 30 | -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/Task 1.py: -------------------------------------------------------------------------------- 1 | numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 2 | total = 0 3 | for num in numbers: 4 | total += num 5 | print("Sum of numbers:", total) -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/Task 2.py: -------------------------------------------------------------------------------- 1 | user_inputs = [] 2 | for i in range(5): 3 | 4 | user_input = input("Enter value {}: ".format(i + 1)) 5 | user_inputs.append(user_input) 6 | 7 | print("You entered:") 8 | for input_value in user_inputs: 9 | print(input_value) 10 | 11 | -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/Task 3.py: -------------------------------------------------------------------------------- 1 | matrix = [ 2 | [1, 2, 3], 3 | [4, 5, 6], 4 | [7, 8, 9] 5 | ] 6 | 7 | for row in matrix: 8 | for element in row: 9 | print(element, end=" ") # Print the element 10 | print() 11 | 12 | max_value = matrix[0][0] #Initial Set a max value 13 | for row in matrix: 14 | for element in row: 15 | if element > max_value: 16 | max_value = element 17 | 18 | print("Maximum value in the matrix:", max_value) 19 | -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/pattern.py: -------------------------------------------------------------------------------- 1 | """ 2 | $ 3 | $$ 4 | $$$ 5 | $$$$ 6 | """ 7 | n =int(input("Enter the Lats number of Pattern:")) 8 | 9 | for i in range(n+1): 10 | print(i*"$") -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/series all number addition.py: -------------------------------------------------------------------------------- 1 | #1 + 2 + 3........+ n 2 | num =int(input("Enter the last number of series:")) 3 | 4 | sum =0 5 | 6 | for x in range(1,num+1,1): 7 | sum = sum +x 8 | 9 | print("series number :",sum) -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/while loop 1.py: -------------------------------------------------------------------------------- 1 | num_iterations = int(input("Enter the number of iterations: ")) 2 | count = 0 3 | 4 | while count < num_iterations: 5 | print("Iteration", count + 1) 6 | count += 1 7 | 8 | print("Loop finished.") 9 | -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/while loop 2.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajjadjim/Basic-Python/327aeaae5a92f26ca7de9c2d9a7b9c4a1a016b42/Lab work 7 (10-02-2024 )/while loop 2.py -------------------------------------------------------------------------------- /Lab work 7 (10-02-2024 )/while loop 3.py: -------------------------------------------------------------------------------- 1 | def factorial(n): 2 | if n < 0: 3 | return "Factorial is not defined for negative numbers" 4 | elif n == 0: 5 | return 1 6 | else: 7 | result = 1 8 | while n > 0: 9 | result *= n 10 | n = n - 1 11 | return result 12 | 13 | num = int(input("Enter a number to find its factorial: ")) 14 | print("Factorial of", num, "is", factorial(num)) 15 | -------------------------------------------------------------------------------- /Lambda Python/Lambda.py: -------------------------------------------------------------------------------- 1 | x = lambda a : a + 10 2 | print(x(5)) 3 | 4 | 5 | x = lambda a , b : a * b 6 | print(x(5,5)) 7 | 8 | x = lambda c , d : c - d 9 | print(x(10,7)) 10 | ''' A lambda function is a small anonymous function. 11 | A lambda function can take any number of arguments, but can only have one expression. ''' 12 | 13 | n = lambda a,b,c,d : (a+b) * (c+d) 14 | print(n(5,6,2,3)) -------------------------------------------------------------------------------- /Lambda Python/function lambda.py: -------------------------------------------------------------------------------- 1 | #1 2 | def my_function(n): 3 | return lambda a : a *n 4 | 5 | myDoubler = my_function(3) 6 | print(myDoubler(11)) 7 | 8 | #2 9 | def myfunc(n): 10 | return lambda a : a * n 11 | 12 | mytripler = myfunc(3) 13 | 14 | print(mytripler(11)) 15 | 16 | 17 | #3 18 | mydoubler = myfunc(2) 19 | mytripler = myfunc(3) 20 | 21 | print(mydoubler(11)) 22 | print(mytripler(11)) 23 | 24 | 25 | -------------------------------------------------------------------------------- /Lambda.py: -------------------------------------------------------------------------------- 1 | x = lambda a, b, c : a + b + c 2 | print(x(5, 6, 2)) 3 | 4 | 5 | def myfunc(n): 6 | return lambda a : a * n 7 | 8 | mydoubler = myfunc(2) 9 | mytripler = myfunc(3) 10 | 11 | print(mydoubler(11)) 12 | print(mytripler(11)) 13 | -------------------------------------------------------------------------------- /LeapYear.py: -------------------------------------------------------------------------------- 1 | def is_leap(year): 2 | return (year % 400 == 0) or (( year % 100 != 0) and (year % 4 == 0)) 3 | year = int(input()) 4 | print(is_leap(year)) -------------------------------------------------------------------------------- /Letter Grade Program.py: -------------------------------------------------------------------------------- 1 | marks= 61 2 | if marks>=80 and marks<=100: 3 | print("A+") 4 | elif marks<=79 and marks>=70: 5 | print("A") 6 | elif marks<=69 and marks>=60: 7 | print("A-") 8 | elif marks <= 59 and marks >= 50: 9 | print("B") 10 | elif marks <= 49 and marks >= 40: 11 | print("C") 12 | elif marks <= 39 and marks >= 33: 13 | print("D") 14 | elif marks <= 32 and marks >= 0: 15 | print("Fail") 16 | else: 17 | print("Invalied Number") 18 | 19 | 20 | -------------------------------------------------------------------------------- /List (Part-1).py: -------------------------------------------------------------------------------- 1 | subjects =["C","C++","Java","Python","Android"] 2 | 3 | print(subjects[0]) 4 | 5 | print(subjects[1]) 6 | 7 | print(subjects) 8 | 9 | print(subjects[-1]) #Reverse Print 10 | 11 | print("Python" in subjects) #check 12 | print("Jim"not in subjects) 13 | 14 | print(subjects + ["jim",5364]) #Add more otems in List 15 | 16 | print(subjects *3 ) #Show the value 3 times 17 | -------------------------------------------------------------------------------- /List Code/List All type of code .py: -------------------------------------------------------------------------------- 1 | my_list= ["Apple" , "Mango" ,"Jackfruit"] 2 | print(my_list) 3 | 4 | 5 | my_list.append("Orange") 6 | print(my_list) 7 | 8 | my_list.insert(0,"Balckberry") 9 | print(my_list) 10 | 11 | 12 | ################# Two List Marge ################### 13 | list1=[1,2,3,4,5] 14 | list2=[6,7,8,9,0] 15 | 16 | list1.extend(list2) 17 | print(list1) 18 | 19 | ################# Touple And List aldo Marge in one List ################ 20 | thislist = ["apple", "banana", "cherry"] 21 | thistuple = ("Bananna", "orange") 22 | thislist.extend(thistuple) 23 | print(thislist) 24 | 25 | 26 | 27 | ##################### Upper Case List ############## 28 | list_uppercase =["sajjad" , "hossain" , "jim"] 29 | newList= [ x.upper() for x in list_uppercase ] 30 | print(newList) 31 | list_lower=["JIM" ,"SAJJAD"] 32 | newList1 =[x.lower() for x in list_lower] 33 | print(newList1) 34 | 35 | 36 | ####################### Sort List Item #################### 37 | list_sort =[2,6,1,9,3,8] 38 | list_sort.sort() 39 | print(list_sort) 40 | 41 | ####################### Reverse The List Item ################## 42 | list_reverse = [12,45,2,78,45,48] 43 | list_reverse.sort(reverse= True) 44 | print(list_reverse) 45 | 46 | 47 | ################### case-insensitive sort of the list: 48 | case_sort=["apple", "orange" ,"Cherry" ,"Pineapple"] 49 | case_sort.sort(key=str.upper) #case_sort.sort(key=str.lower) 50 | print(case_sort) 51 | 52 | 53 | 54 | # reverse The List Item 55 | reverse_list=[100,99,91,88,50,45,30] 56 | reverse_list.reverse() 57 | print(reverse_list) 58 | 59 | 60 | ############################## Copy Nad List List item ################ 61 | copy_list = [1,2,3,4,5,6,7] 62 | new_copy =copy_list.copy() 63 | print(new_copy) 64 | 65 | 66 | list_list =[11,22,33,44,55,66] 67 | list_list1 =list(list_list) 68 | print(list_list1) 69 | 70 | 71 | 72 | 73 | ############### Join two List 74 | list1 = ["a", "b", "c"] 75 | list2 = [1, 2, 3] 76 | 77 | list3 = list1 + list2 78 | print(list3) 79 | 80 | #Second Model 81 | list1 = ["a", "b" , "c"] 82 | list2 = [1, 2, 3] 83 | for x in list2: 84 | list1.append(x) 85 | 86 | print(list1) 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /List Code/number to List convert.py: -------------------------------------------------------------------------------- 1 | number_data="123456789" 2 | convert_list=[(num) for num in number_data] 3 | print(f"Numvber to list convert->>>{convert_list}") 4 | -------------------------------------------------------------------------------- /Loop/For Loop.py: -------------------------------------------------------------------------------- 1 | num =[11,22,33,44,55,66,77,88,99] 2 | sum =0 3 | for x in num: 4 | print(x) 5 | sum= sum +x 6 | 7 | print("Totall Number of value:",sum) -------------------------------------------------------------------------------- /Loop/Nasted Loop 1.py: -------------------------------------------------------------------------------- 1 | adj =["Mango" , "JackFruits" , "BlackBarry"] 2 | second=["Tree" ,"Onnion" ,"Runner"] 3 | 4 | for i in adj: 5 | for j in second: 6 | print(i,j) 7 | 8 | for x in [0, 1, 2]: 9 | pass # for loops cannot be empty, but if you for some reason have a for loop with no content, put in the pass statement to avoid getting an error. 10 | 11 | -------------------------------------------------------------------------------- /Loop/nested loop.py: -------------------------------------------------------------------------------- 1 | 2 | for i in range(1,6): 3 | for j in range(1,i+1): 4 | print("*",end= " ") 5 | print() 6 | 7 | for i in range(6,0,-1): 8 | for j in range(1,i+1): 9 | print("*",end= " ") 10 | print() 11 | 12 | 13 | 14 | #print("i=",i,"\t j=",j) 15 | -------------------------------------------------------------------------------- /Number write sequence.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | n = int(input()) 3 | 4 | for number in range(1, n + 1): 5 | print(number, end='') 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Numerical.py: -------------------------------------------------------------------------------- 1 | a = 10 2 | 3 | b = 5 4 | 5 | print("Sumation = ",a+b) 6 | print("Minus value = ",a-b) 7 | print(a%b) 8 | print(a*b) 9 | print(a//b) 10 | print(a**b) 11 | 12 | print("Value of =",10+4) 13 | -------------------------------------------------------------------------------- /Object ,class/A practical example of inheritance.py: -------------------------------------------------------------------------------- 1 | class shape: 2 | def __init__(self,dim1,dim2): 3 | self.dim1=dim1 4 | self.dim2=dim2 5 | 6 | def area(self): 7 | print("I am area method of shape class") 8 | 9 | 10 | class triangle(shape): 11 | def area(self): 12 | area= 0.5 * self.dim1 * self.dim2 13 | print("Area of Triangle :", area) 14 | 15 | 16 | class rectangle(shape): 17 | def area(self): 18 | area= self.dim1 * self.dim2 19 | print("Area of rectangle :", area) 20 | 21 | t1=triangle(20,30) 22 | t1.area() 23 | r1=rectangle(20,30) 24 | r1.area() -------------------------------------------------------------------------------- /Object ,class/Basic 1.py: -------------------------------------------------------------------------------- 1 | class student: 2 | name = " " 3 | roll = "" 4 | 5 | std1 = student() 6 | std1.name = "Rahim" 7 | std1.roll = 11 8 | print(f"Name -> {std1.name} , Roll -> {std1.roll}") 9 | 10 | std2 = student() 11 | std2.name = "Sajjad Jim" 12 | std2.roll = 5364 13 | print(f"Name -> {std2.name} , Roll -> {std2.roll}") -------------------------------------------------------------------------------- /Object ,class/Inheritance.py: -------------------------------------------------------------------------------- 1 | class phone : 2 | def call(self): 3 | print("ANy one Can call in phone ...........") 4 | 5 | def picture(self): 6 | print("Any one can take photo with phone......") 7 | 8 | 9 | class pixel(phone): 10 | def name(self): 11 | print("pixel 6 phone...........") 12 | 13 | pixel1 = pixel() 14 | pixel1.name() 15 | pixel1.call() 16 | pixel1.picture() -------------------------------------------------------------------------------- /Object ,class/Method Overriding.py: -------------------------------------------------------------------------------- 1 | class phone: 2 | def __int__(self): 3 | print("I am in the phone class") 4 | 5 | 6 | class samsung(phone): 7 | def __int__(self): 8 | super().__int__() 9 | print("i am in the samsung class") 10 | 11 | 12 | s = samsung() -------------------------------------------------------------------------------- /Object ,class/Method create.py: -------------------------------------------------------------------------------- 1 | class student: 2 | name = " " 3 | roll = "" 4 | 5 | def set_Value(self,name , roll): 6 | self.name = name 7 | self.roll = roll 8 | 9 | def display(self): 10 | print(f"Name ->{self.name}, Roll number ->>{self.roll}") 11 | 12 | std1 = student() 13 | std1.set_Value("Sajjad Hossain jim" ,5364) 14 | std1.display() 15 | 16 | std2 = student() 17 | std2.set_Value("Siam",101) 18 | std2.display() 19 | -------------------------------------------------------------------------------- /Object ,class/Multiple Inheritance.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def display1(self): 3 | print("I am in A class.......") 4 | 5 | class B(): 6 | def display2(self): 7 | print("I am in B class.......") 8 | 9 | class C(A,B): 10 | def display3(self): 11 | super().display1() 12 | self.display2() # Call display2 directly from self 13 | print("I am in C class.......") 14 | 15 | c1 = C() 16 | c1.display3() 17 | -------------------------------------------------------------------------------- /Object ,class/Practice constructore.py: -------------------------------------------------------------------------------- 1 | class TriAngle : 2 | def __init__(self ,base, height , ): 3 | self.base = base 4 | self.height = height 5 | 6 | def Calculate(self): 7 | area = 0.5 * self.base * self.height 8 | print(f"Area Print ->{area}") 9 | 10 | t1 = TriAngle(5,6) 11 | t1.Calculate() 12 | 13 | t2 = TriAngle(10,10) 14 | t2.Calculate() -------------------------------------------------------------------------------- /Object ,class/construictor.py: -------------------------------------------------------------------------------- 1 | class student: 2 | name = " " 3 | roll = "" 4 | 5 | def __int__(self,name ,roll): 6 | self.name = name 7 | self.roll = roll 8 | 9 | def display(self): 10 | print(f"Name ->{self.name}, Roll number ->>{self.roll}") 11 | 12 | std1 = student("Sajjad Jim",5364) 13 | std1.display() 14 | 15 | std2 = student("Siam",101) 16 | std2.display() 17 | -------------------------------------------------------------------------------- /Pattern/Pattern 2.py: -------------------------------------------------------------------------------- 1 | """ 2 | * 3 | *** 4 | ***** 5 | ******* 6 | ********* 7 | """ 8 | n =int(input("Enter the Lats number of Pattern:")) 9 | 10 | for i in range(n+1): 11 | print((2*i-1)*"*") -------------------------------------------------------------------------------- /Pattern/Pattern.py: -------------------------------------------------------------------------------- 1 | """ 2 | * 3 | ** 4 | *** 5 | **** 6 | ***** 7 | """ 8 | n =int(input("Enter the Lats number of Pattern:")) 9 | 10 | for i in range(n+1): 11 | print(i*"*") -------------------------------------------------------------------------------- /Prime number find.py: -------------------------------------------------------------------------------- 1 | # Prime Number or Not prime Number 2 | 3 | 4 | def check_prime(num): 5 | if num <= 1: 6 | return False 7 | for i in range(2, num): 8 | if num % i == 0: 9 | return False 10 | 11 | return True 12 | 13 | user_input = int(input("Enter an integer number: ")) 14 | 15 | if check_prime(user_input): 16 | print(f"{user_input} is a prime number") 17 | else: 18 | print(user_input, "is not a prime number.") 19 | 20 | -------------------------------------------------------------------------------- /Print Division.py: -------------------------------------------------------------------------------- 1 | if __name__ == '__main__': 2 | a = int(input()) 3 | b = int(input()) 4 | division = a/b 5 | print(int(division)) 6 | print(float(division)) -------------------------------------------------------------------------------- /Program file.py: -------------------------------------------------------------------------------- 1 | #My name is jim 2 | print(max(10,20)) 3 | print(min(20,7)) 4 | -------------------------------------------------------------------------------- /Python Class/Class.py: -------------------------------------------------------------------------------- 1 | #Create a Class 2 | class MyClass : 3 | x = 5 4 | 5 | p1 = MyClass() #MyClass class initial the new name 6 | print(p1.x) 7 | 8 | #New Code 9 | class Person: 10 | #Note: The __init__()function is called automatically every time the class is being used to create a new object. 11 | def __init__(self, name, age): 12 | self.name = name 13 | self.age = age 14 | 15 | p1 = Person("Sajjad Hossain Jim", 36) 16 | print(p1.name , p1.age) 17 | print(p1) 18 | -------------------------------------------------------------------------------- /Python Class/class 2.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, name, age): 3 | self.name = name 4 | self.age = age 5 | 6 | def __str__(self): 7 | return f"{self.name}({self.age})" 8 | 9 | p1 = Person("Sajjad Hossain Jim" , 25) 10 | print(p1) 11 | 12 | 13 | #ANother Code 14 | class Person: 15 | def __init__(self, name, address): 16 | self.name = name 17 | self.address = address 18 | 19 | def myfunc(self): 20 | print("Hello my name is " + self.name) 21 | print("I am a student of " + self.address) 22 | 23 | P1=Person("Sajjad Hossain Jim" , "Daffodil International University" ) 24 | P1.myfunc() -------------------------------------------------------------------------------- /Python Class/self parameter.py: -------------------------------------------------------------------------------- 1 | class MyClass: 2 | def __init__(mysillyobject , name , age): 3 | mysillyobject.name = name 4 | mysillyobject.age = age 5 | 6 | 7 | def myFunction(abc): 8 | print("My name is " +abc.name) 9 | print("I am " ,abc.age ,"Years Old") 10 | 11 | p1=MyClass("Sajjad Jim" , 25) 12 | p1.myFunction() 13 | 14 | p1.age=40 15 | del p1.age -------------------------------------------------------------------------------- /Quiz 3 Rifat/1.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | # Base class for Vehicle 3 | class Vehicle: 4 | def __init__(self, registration_number, model_number, year_of_manufacture, rental_fee): 5 | self.registration_number = registration_number 6 | self.model_number = model_number 7 | self.year_of_manufacture = year_of_manufacture 8 | self.rental_fee = rental_fee 9 | def display_info(self): 10 | print(f"Registration Number: {self.registration_number}") 11 | print(f"Model Number: {self.model_number}") 12 | print(f"Year of Manufacture: {self.year_of_manufacture}") 13 | print(f"Rental Fee: ${self.rental_fee:.2f} per day") 14 | 15 | # Subclass for Car 16 | class Car(Vehicle): 17 | def __init__(self, registration_number, model_number, year_of_manufacture, rental_fee, number_of_doors): 18 | super().__init__(registration_number, model_number, year_of_manufacture, rental_fee) 19 | self.number_of_doors = number_of_doors 20 | 21 | def display_info(self): 22 | super().display_info() 23 | print(f"Number of Doors: {self.number_of_doors}") 24 | 25 | # Subclass for Truck 26 | class Truck(Vehicle): 27 | def __init__(self, registration_number, model_number, year_of_manufacture, rental_fee, payload_capacity): 28 | super().__init__(registration_number, model_number, year_of_manufacture, rental_fee) 29 | self.payload_capacity = payload_capacity 30 | 31 | def display_info(self): 32 | super().display_info() 33 | print(f"Payload Capacity: {self.payload_capacity} kg") 34 | 35 | # Booking class to manage rentals 36 | class Booking: 37 | def __init__(self, customer_name, nid, phone_number, vehicle, start_date, end_date, advance_payment=False): 38 | self.customer_name = customer_name 39 | self.nid = nid 40 | self.phone_number = phone_number 41 | self.vehicle = vehicle 42 | self.start_date = start_date 43 | self.end_date = end_date 44 | self.advance_payment = advance_payment 45 | 46 | def calculate_rental_fee(self): 47 | duration = (self.end_date - self.start_date).days 48 | total_fee = duration * self.vehicle.rental_fee 49 | return total_fee 50 | 51 | def display_booking_info(self): 52 | print(f"Customer Name: {self.customer_name}") 53 | print(f"NID: {self.nid}") 54 | print(f"Phone Number: {self.phone_number}") 55 | print("Vehicle Information:") 56 | self.vehicle.display_info() 57 | print(f"Start Date: {self.start_date.strftime('%Y-%m-%d')}") 58 | print(f"End Date: {self.end_date.strftime('%Y-%m-%d')}") 59 | print(f"Advance Payment: {'Yes' if self.advance_payment else 'No'}") 60 | print(f"Total Rental Fee: ${self.calculate_rental_fee():.2f}") 61 | 62 | # Example usage: 63 | if __name__ == "__main__": 64 | # Create instances of Car and Truck 65 | car = Car("CAR123", "ModelX", 2021, 50.0, 4) 66 | truck = Truck("TRK456", "ModelY", 2019, 75.0, 1000) 67 | 68 | # Display vehicle information 69 | print("Car Information:") 70 | car.display_info() 71 | print("\nTruck Information:") 72 | truck.display_info() 73 | print("\n") 74 | 75 | # Create a booking for the car 76 | start_date = datetime(2024, 5, 27) 77 | end_date = datetime(2024, 5, 30) 78 | booking = Booking("John Doe", "NID12345", "123-456-7890", car, start_date, end_date, advance_payment=True) 79 | 80 | # Display booking information 81 | print("Booking Information:") 82 | booking.display_booking_info() 83 | -------------------------------------------------------------------------------- /Quiz 3 Rifat/2.py: -------------------------------------------------------------------------------- 1 | def calculate_average(): 2 | try: 3 | # Prompt the user to enter a list of numbers separated by spaces 4 | user_input = input("Enter a list of numbers separated by spaces: ") 5 | 6 | # Split the input string into a list of numbers 7 | number_strings = user_input.split() 8 | 9 | # Convert the list of strings to a list of floats 10 | numbers = [float(num) for num in number_strings] 11 | 12 | if not numbers: 13 | raise ValueError("The list is empty.") 14 | 15 | # Calculate the average of the numbers in the list 16 | average = sum(numbers) / len(numbers) 17 | 18 | # Display the calculated average 19 | print(f"The average of the numbers is: {average}") 20 | 21 | except ValueError as ve: 22 | # Handle non-numeric inputs or empty list 23 | print(f"Error: {ve}") 24 | 25 | except Exception as e: 26 | # Handle any other unexpected errors 27 | print(f"An unexpected error occurred: {e}") 28 | 29 | finally: 30 | # Display a goodbye message 31 | print("Goodbye!") 32 | 33 | 34 | # Call the function to execute the program 35 | calculate_average() 36 | -------------------------------------------------------------------------------- /Random number guess.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | secret_number = random.randint(1, 20) 4 | 5 | print("Welcome to the Guessing Game !!") 6 | print("Try to guess the secret number between 1 and 20.") 7 | 8 | # Set initial values 9 | attempts = 0 10 | max_attempts = 5 11 | guess = None 12 | 13 | while attempts < max_attempts: 14 | guess = int(input("Enter your guess: ")) 15 | 16 | # Check if the guess is correct 17 | if guess == secret_number: 18 | print("Congratulations! You guessed the secret number in", attempts + 1, "attempts.") 19 | break 20 | elif guess < secret_number: 21 | print("Too low. Try again.") 22 | else: 23 | print("Too high. Try again.") 24 | 25 | attempts += 1 26 | 27 | # If the player couldn't guess within the allowed attempts 28 | if guess != secret_number: 29 | print("Sorry, you've run out of attempts. The secret number was:", secret_number) 30 | -------------------------------------------------------------------------------- /Relational Operator & Boolean Data Type.py: -------------------------------------------------------------------------------- 1 | print(20== 30) 2 | print(20 > 11) 3 | print(50 >= 40) 4 | print(30!=20) 5 | print(11<= 7) 6 | print("sajjad" == "sajjad") 7 | print("jim15" == "jim") 8 | -------------------------------------------------------------------------------- /Square_root.py: -------------------------------------------------------------------------------- 1 | print("my code") 2 | print("sajjad hosssain jim") 3 | -------------------------------------------------------------------------------- /Sum of n numbers.py: -------------------------------------------------------------------------------- 1 | # 1 + 2 + 3 +......N 2 | n =int(input("Enter the last number :")) 3 | sum = 0 4 | i =1 5 | while i<=n: 6 | sum = sum +i 7 | i = i+1 8 | 9 | print(sum) 10 | -------------------------------------------------------------------------------- /Ternary Operator.py: -------------------------------------------------------------------------------- 1 | num1 = 10 2 | num2= 13 3 | """ 4 | if num1>num2: 5 | print(num1) 6 | else: 7 | print(num2) 8 | """ 9 | print("The largest number:",num1 if num1>num2 else num2) 10 | -------------------------------------------------------------------------------- /Two number add and print .py: -------------------------------------------------------------------------------- 1 | print("My code") 2 | print("My code is runnning ") 3 | a = 20 4 | b = 30 5 | print(a+b) 6 | 7 | -------------------------------------------------------------------------------- /Typecasting.py: -------------------------------------------------------------------------------- 1 | num1 = int(input("Enter first number :")) 2 | num2 = int(input("Enter second number :")) 3 | 4 | result = (num1) + (num2) 5 | print("The sum value is :",result) 6 | 7 | result = (num1) - (num2) 8 | print("The sum value is :",result) 9 | 10 | result = (num1) - (num2) 11 | print("The sum value is :",result) 12 | -------------------------------------------------------------------------------- /a web scraper.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pip install requests beautifulsoup4 4 | 5 | 6 | 7 | import requests 8 | from bs4 import BeautifulSoup 9 | 10 | # Function to scrape a webpage 11 | def scrape_website(url): 12 | try: 13 | # Send a GET request to the URL 14 | response = requests.get(url) 15 | response.raise_for_status() # Raise HTTPError for bad responses (4xx and 5xx) 16 | 17 | # Parse the webpage content 18 | soup = BeautifulSoup(response.text, 'html.parser') 19 | 20 | # Extract all titles and links (for example, 'a' tags with 'href' attribute) 21 | links = soup.find_all('a', href=True) 22 | 23 | # Print the extracted links and text 24 | for link in links: 25 | text = link.get_text(strip=True) # Get link text 26 | href = link['href'] # Get link URL 27 | print(f"Text: {text}, Link: {href}") 28 | except requests.exceptions.RequestException as e: 29 | print(f"Error fetching the webpage: {e}") 30 | 31 | # Example usage 32 | url = "https://example.com" # Replace with the URL you want to scrape 33 | scrape_website(url) 34 | -------------------------------------------------------------------------------- /break and continue.py: -------------------------------------------------------------------------------- 1 | i=1 2 | while i<=100: 3 | print(i) 4 | i = i + 1 5 | if i==20: 6 | break #continue 7 | 8 | 9 | print("My name is jim") -------------------------------------------------------------------------------- /elements of matrix.py: -------------------------------------------------------------------------------- 1 | n = 3 2 | m = 3 3 | arr = [[3, 2, 7], [2, 6, 8], [5, 1, 9]] 4 | sum = 0 5 | 6 | # Iterating over all 1-D arrays in 2-D array 7 | for i in range(n): 8 | # Printing all elements in ith 1-D array 9 | for j in range(m): 10 | # Printing jth element of ith row 11 | sum += arr[i][j] 12 | 13 | print(sum) 14 | 15 | # This code id contributed by shivhack999 16 | -------------------------------------------------------------------------------- /elif statement.py: -------------------------------------------------------------------------------- 1 | marks = 40 2 | if marks>=80 : 3 | print("Your got A+") 4 | 5 | elif marks>=70: 6 | print("You got A") 7 | 8 | elif marks>= 60: 9 | print("You got A-") 10 | 11 | elif marks >= 50: 12 | print("You got B") 13 | 14 | elif marks >= 40: 15 | print("You Got C ") 16 | 17 | elif marks >= 33: 18 | print("You are Pass in Exam") 19 | 20 | else: 21 | print("You are Fail....") 22 | -------------------------------------------------------------------------------- /if, else statement.py: -------------------------------------------------------------------------------- 1 | #Pass / Faill 2 | marks = 30 3 | if marks>=33: 4 | print("Pass") 5 | if marks<33: 6 | print("Fail") 7 | 8 | print("Your got your Result.....") 9 | 10 | #Largest Number 11 | num1 = 20 12 | num2 = 11 13 | 14 | if num1>num2: 15 | print("The Largest number:",num1) 16 | 17 | else: 18 | print("The largest Number:",num2) 19 | 20 | 21 | #Even/ODD number find 22 | num = 10 23 | if num%2 ==0: 24 | print("Even number.......") 25 | else: 26 | print("Odd number.......") 27 | -------------------------------------------------------------------------------- /inheritance.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, fname, lname): 3 | self.firstname = fname 4 | self.lastname = lname 5 | 6 | def printname(self): 7 | print(self.firstname, self.lastname) 8 | 9 | #Use the Person class to create an object, and then execute the printname method: 10 | 11 | x = Person("John", "Doe") 12 | x.printname() 13 | -------------------------------------------------------------------------------- /input.py: -------------------------------------------------------------------------------- 1 | name = input("Enter your name =") 2 | age = input("Enter your age =") 3 | 4 | 5 | print("~~~~~ Student Information ~~~~~") 6 | print("Name is ",name) 7 | print("Age ",age) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /series/series 1.py: -------------------------------------------------------------------------------- 1 | #1 + 2 + 3........+ n 2 | num =int(input("Enter the last number of series:")) 3 | 4 | sum =0 5 | 6 | for x in range(1,num+1,1): 7 | sum = sum +x 8 | 9 | print("series number :",sum) -------------------------------------------------------------------------------- /series/series 2.py: -------------------------------------------------------------------------------- 1 | #2 + 4 + 6........+ n 2 | num =int(input("Enter the last number of series:")) 3 | 4 | sum =0 5 | 6 | for x in range(2,num+1,2): 7 | sum = sum +x 8 | 9 | print("series number :",sum) -------------------------------------------------------------------------------- /series/series 3.py: -------------------------------------------------------------------------------- 1 | #1^2 + 2^2 + 3^2........+ n^2 2 | num =int(input("Enter the last number of series:")) 3 | 4 | sum =0 5 | 6 | for x in range(1,num+1,1): 7 | sum = sum + x*x 8 | 9 | print("series number :",sum) -------------------------------------------------------------------------------- /series/series 4.py: -------------------------------------------------------------------------------- 1 | # 1 x 2 x 3 ........x n 2 | num =int(input("Enter the last number of series:")) 3 | 4 | sum =1 5 | 6 | for x in range(1,num+1,1): 7 | sum = sum * x 8 | 9 | print("series number :",sum) -------------------------------------------------------------------------------- /square Root.py: -------------------------------------------------------------------------------- 1 | x = 10 2 | y = 2 3 | 4 | 5 | value = x ** y 6 | 7 | print(5 ** 3) # 125 8 | print(2 ** 3) # 8 9 | print(value) # 100 10 | print(x ** 2) ##100 -------------------------------------------------------------------------------- /while loop.py: -------------------------------------------------------------------------------- 1 | i =1 2 | while i<=20: 3 | print(i,".Bangladesh") 4 | i = i+1 5 | print("Programn Has been finished") 6 | --------------------------------------------------------------------------------