Posts

Online Library system | Made with python

Online Library system Code -- ------------------------------- import time def getdate():     return time.asctime() class Library:     # list_of_books = ["S.Sc. All in one", "Maths R.D. Sharma", "D.K.", "Maths N.C.E.R.T."]     def __init__(self, book_list, library_name):         self.list_of_books = book_list         self.library_name = library_name     def display_book(self):         print("Displaying...")         time.sleep(1)         return f"{self.list_of_books}\n"     def lend_book(self):         name = input("Enter your name: ")         name_of_book = input("Enter the name of book which you want to borrow: ")         if name_of_book not in self.list_of_books:             print("Book not available !! or incorrect book name entered !!")   ...

Diamond Shape problem in python.

  Diamond Shape problem in python. Code -  ------------------------------------- class A:     def met(self):         return "Hello this is a diamond shape problem of class A" class B(A):     def met(self):         return "Hello this is a diamond shape problem of class B" class C(A):     def met(self):         return "Hello this is a diamond shape problem of class C " class D(B, C):     def met(self):         return "Hello this is a diamond shape problem of class D" a = A() b = B() c = C() d = D() print(d.met())

Over & Super in python.

 Over & Super in python. Code - ------------------------------ class A : classvar1 = "Class variable of class A" def __init__ ( self ): self .var1 = "Instance variable of class A" self .special = "This is special variable" self .instance_variable = "Instance variable of class A" class B (A): classvar1 = "Class variable of class B" def __init__ ( self ): self .var1 = "Instance variable of class B" self .instance_variable = "Instance variable of class B" super (). __init__ () # print(super(B, self).classvar1) hello = A() by = B() # print(by.special) print (by.var1, by.instance_variable) # print(by.var1) # print(by.classvar1)

Single Inheritance, multiple inheritance and multilevel inheritance in python.

Multilevel inheritance in python  A program as an example. Code - -------------------------------- class ElectronicDevice:     refrigerator = 1000     def __init__(self, name, watt):         self.name = name         self.watt = watt     def rupee_checker(self):         a = 283         if self.watt < 1000:             return f"Your Electrical Device consumes less than {a} units per year."         elif self.watt > 1000:             return f"Your Electrical Device consumes more than {a} units per year."         elif self.watt == 1000:             return f"Your Electrical Device consumes {a} units per year." class PocketGadget(ElectronicDevice):     MaH = 3000     def __init__(self, name, mah):         se...

Using class objects, Instance variables, and class variables, class methods and static method in python

  Using class objects, Instance variables, and class variables, class methods and static method in python Code - ------------------------------------ class Students:     number_of_buildings = 4     # def Majra(self):     #     return f"Number of toys are {self.toys}, and number of buildings are {self.number_of_buildings}"     def __init__(self, name, aclass, section, rollnumber, school, stream):         self.name = name         self.standard = aclass         self.section = section         self.Roll_number = rollnumber         self.School = school         self.stream = stream     def eye_checker(self):         return f"Class is {self.standard}, and name is {self.name}"     @classmethod     def hello(cls, no_of_new_buildings):         cls.numb...

Song player | Made by python

  Song player Obviously it's not that much perfect as windows or phone's music player's are but for me it's enough to use in this we can play music specifically and in mixture also.. ------------------------------------------- from playsound import playsound opinion = input ( "In which type you want to listen songs.. \n 1: For specifically.. \n 2: For mix continiously... \n " ) if opinion == '1' : print ( "Songs available \n 1: Alan Walker - Fade \n 2: Alan Walker - Force \n 3: Alan Walker - Spectre \n 4: Cartoon - On & On \n 5: Different Heaven & EH!DE - My Heart \n 6: Jarico - Landscape " ) song = input ( "Enter the number of song which you want to here \n " ) if song == "1" : print ( "Playing..." ) playsound( 'D: \\ d data \\ tunes 3 \\ Alan Walker - Fade [NCS Release].mp3' ) elif song == "2" : print ( "Playing..." ) pl...

Health Management System | Made with python.

  Health Management System This system basically works for 3 persons Harry, Rohan and Hammad. Their food and exercise is recorded. ----------------------------- def getdate (): import datetime return datetime.datetime.now() def see (a): if a== '1' : h= input ( "For food enter f and for exercise enter e: " ) if h== "f" : with open ( "harry-food.txt" ) as f: content = f.read() print (content) elif h== "e" : with open ( "harry-exercise.txt" ) as f: content = f.read() print (content) else : print ( "Enter f or e !" ) elif a== '2' : r = input ( "For food enter f and for exercise enter e: " ) if r == "f" : with open ( "rohan-food.txt" ) as f: content = f.read() print (content) ...

Study recorder made with python.

Study recorder This program just record the topics what ever you have studied in specified subjects. And after some time you can also check out the topics what you have studied... def getdate():     import datetime     return datetime.datetime.now() print("[This is a Study Recorder programme which recordes your study topics on various subjects.]") try:     while (True):         opinion = input("For recording a record enter 1 and to look a record of any subject enter 2\n")         if opinion == '2':             print("Your subjects:-\n1: Accounts\n2: Economics\n3: Business Studies\n4: English\n5: Music")             Rsubject = input("Enter the subject's number which you want to\nsee the topics which you have learn\n")             if Rsubject == "1":                 print("You chosed 1 for Ac...

Water Assistant | Made with python

  Water Assistant | Made with python Basically I made this program to manage my water consumed in a day and it helped me a lot.. ______________________ import datetime print("Hi! I am you Water Assistant !") clear = input("Starting new day press enter for clearing old stuff.. and not then press 1: ") anticlear = '' if clear == '':     with open("Waterdate.txt", "w") as f:         f.write(anticlear)     with open("waterdetail.txt", "w") as f:         f.write(anticlear)     print("Data cleared now start you newly fresh day...:))") else:     pass def time():     """to get date and time """     date = datetime.datetime.now()     return date with open("waterdetail.txt", "r") as f:     # just for printing previous value     content = f.read() with open("waterdate.txt", "r") as f:     date1 = f.read()     # pahaile se hi number of glasses ...

Join function in python.

 Join function in python. abc = ["Technical Guruji", "A2motivation",        "Trakin tech", "Aastha Creations", "Techza Gaming"] # for index, item in enumerate(abc): #     print(item, "and", end=" ") # a = "and".join(abc) a = " and ".join(abc) print(f"{a}many more are very famous youtubers..")

Snake, Water, Gun.. game made with python

 Snake, Water, Gun import random from playsound import playsound cpoints = 0 upoints = 0 print ( "Welcome to my game , read instructions carefully and enjoy the game :))" ) print ( "Choose from the following each time.. \n S:- For Snake \n W:- For Water \n G:- For Gun" ) print ( "Remember to write your choise in Capital each time otherwise your choice will not be taken by the computer" ) for i in range ( 10 ): objects = [ "Snake" , "Water" , "Gun" ] computer = random.choice(objects) user = input ( "Now enter your choice: " ) if user == "S" and computer == "Snake" : print ( "Same choice" , " \t\t\t\t\t\t\t You=" , upoints, ",Computer=" , cpoints) playsound( 'D: \\ game sounds \\ same choice1.mp3' ) elif user == "S" and computer == "Water" : upoints+= 1 print ( "Results \n You-Snake...

How to find median | Class 10 | Updated a program made with python.

Find median of group data . As I made a median finder made with python , it was working but finding wrong answer but now I have updated that and this updated program is working properly and giving correct answer. So here is the code. def median (l,n,cf,f,h): """This is a functions to find median of given group data you have to put only the required values """ a=n/ 2 b=a-cf c=b/f d=c*h x=d+l return x print ( "This is a calculator which calculate median" ) print ( "So first put value of l" ) l= int ( input ()) print ( "Now enter the value of n" ) n= int ( input ()) print ( "Put value of cf" ) cf= int ( input ()) print ( "Enter value of f" ) f= int ( input ()) print ( "put value of h" ) h= int ( input ()) print ( "Your median of given values is" ,median(l,n,cf,f,h))

How to write a Python program for taking input from user for implementing assignment operators on it?

How to write a Python program for taking input from user for implementing assignment operators on it? First you have to take input from user by input command and for testing assignment operator you have to typecast it into an integer and after this I just wanted to tell that Assignment operators in python assign a value in a variable , like to add a digit in a variable's value which is an int , or adding a digit using assignment operator in a variable's value which is entered by the user for doing this here is a code for and example -- x= int ( input ( "Enter your number" )) x+= 5 print ( "After adding 5 in your number-" ,x) #after this we can also do subtraction from the entered number entered by the user x-= 5. print ( "After subtracting 5 from your number-" ,x) One thing which is to be remembered is that after using "x-=5" it will change the real digit which is stored in the variable. For example if you enter 10 in the input in the cod...

Guess the hidden number | Game | Made with Python

 Guess the hidden number   Hello everyone so here is my another code , It is a game in which a number is hidden a the user have to guess the number their are 10 chances to guess that number , after  each  guess it will tell the number you entered is bigger than hidden number or smaller. Enjoy the game.   x= 25 print ( "In this game you have to guess the number which is hidden, \n You have 10 chances to guess the hidden number" ) chances= 1 while ( True ): guess= int ( input ( "Now enter your number \n " )) if guess==x: print ( "Congrats you won by" ,chances, "guesses" ) opinion= input ( "To play again write yes and to exit write exit \n " ) opinion.upper() if opinion== 'Yes' : continue else : print ( "Hope you enjoyed the game" ) break if guess>x : print ( "Your number is bigger than hidden number \n Try again" ...

Basic calculator made with python...

 Basic calculator made with python... So basically made this calculator by using If , Else and Elif conditions in Python... while ( True ): print ( "Actions available \n ('+','-','*','**','/')" ) a= int ( input ( "Enter your first number \n " )) sign= input ( "Enter operator \n " ) b= int ( input ( "Enter your second number \n " )) if sign== '+' : print ( "Your addition is" ,a+b) elif sign== '-' : print ( "Your subtraction is" ,a-b) elif sign== '/' : print ( "Your division is" , a / b) elif sign== '*' : print ( "Your multiplication is" , a * b) elif sign== '**' : print ( "Your power is" , a ** b) else : print ( "Error! Unexpected sign or values" ) opinion= input ( "For using this calculator again enter yes and for...

Driving eligibility teller program made with python.

 A program which tells that you are eligible to drive or not.  print ( "Enter your age" ) age= int ( input ()) if age> 18 : print ( "tussi to pakka gaddi chala loge" ) if age< 18 : print ( "na beta tumse drive na ho paega" ) if age== 18 : print ( "beta pahaili fursat me apna lisence banvale " ) #upper one code is normal but next one is advance in which someone tell his/her age like impossible then our program will not be confused.. #advance driving age checker print ( "enter your age" ) age= int ( input ()) if age<= 12 and age>= 1 : print ( "you should not even think about driving" ) elif age> 12 and age< 18 : print ( "you can't drive" ) elif age== 18 : print ( "Go and get a driving license first" ) elif age> 18 and age< 60 : print ( "Absolutely you can drive" ) else : print ( "You are joking" ) I have made these by using If , E...