Posts

Showing posts from January, 2021

COMPREHENSION TASK

  EXIT = False while (EXIT is not True ): start_exit = input ( "Enter S for Start Enter E for Exit: " ) if start_exit == 'E' : exit () elif start_exit == 'S' : no_of_item = int ( input ( "Enter Number of Item want in list: " )) input_string = input ( "Enter a list element separeted by space: " ) list = input_string.split( " " ) if len (list)>no_of_item: print ( "Maximum Element Entry" ) elif len (list)<no_of_item: print ( "Minimum Element Entry" ) else : t = int ( input ( "Which type of comprehension you want to use \n 1 for list, 2 for Dictionary and press 3 for set: " )) if t == 1 : ls = [i for i in list] print (ls) print ( type (ls)) elif t == 2 : dic = { f"item { i } " : i for i in list} ...

Library System

  # creat a library class # display book # lend book (who own the book if not present) # add book # return book # Suman Library = Library(listofbooks, library_name) # dictionary (book-nameofperson) class Library(): list_of_book = [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' ] lender = { 'blank' : 'blank' } def booklist( cls ): print ( cls .list_of_book) print ( f"THE ABOUVE BOOK BYDEFAULT REGISTER IN YOUR LIBRARY" ) i = 0 while i< 10 : con = input ( "PRESS 'Y' TO ADD MORE BOOK IN REGISTER \n PRESS 'N' TO GOTHROUGH WITH DEFAULT BOOK: " ) if con == 'Y' : book_list = input ( "Enter the book name to add in Library: " ) cls .list_of_book.append(book_list) i += 1 if con == 'N' : break def display( cls ): retur...

NotePad - My 1st Project

  from tkinter import * from tkinter.messagebox import showinfo from tkinter.filedialog import askopenfilename, asksaveasfilename import os def newfile (): global file note_root.title( "Untitled - NotePad" ) file = None TextArea.delete( 1.0 , END) def openfile(): global file file = askopenfilename( defaultextension = ".txt" , filetypes =[( "All Files" , "*.*" ), ( "Text Documents" , "*.txt" )]) if file == "" : file = None else : note_root.title(os.path.basename(file) + " - Notepad" ) TextArea.delete( 1.0 , END) f = open (file, "r" ) TextArea.insert( 1.0 , f.read()) f.close() def savefile(): global file if file == None : file = asksaveasfilename(initialfile= "Untitled.txt" , defaultextension= ".txt" , filetypes=[( "All Files" , "*.*" ), ( "Text Documents"...