Posts

Virus Detecter

  import os def detectVirus (filename): with open (filename, "r" ) as f: lines = f.read() if "virus" in lines.lower(): return True else : return False if __name__ == '__main__' : contents_list = os.listdir() count = 0 for content in contents_list: if content.endswith( "txt" ): print ( f"Detecting Virus In { content } " ) flag = detectVirus(content) if flag: print ( f"Virus Found in { content } " ) count += 1 else : print ( f"Virus Not Found in { content } " ) print ( f" \n{ count } Files Have Virus Hidden in Them" )

Currency Converter

Include 'Currency.txt' From Here https://codewithashishpython.blogspot.com/2020/08/currencytxt.html with open ( "Currency.txt" , "r" ) as f: currencyList = f.readlines() currencyDict = {} for line in currencyList: parseList = line.split( " \t " ) currencyDict[parseList[ 0 ]] = parseList[ 1 ] amount = int ( input ( "Enter The Amount In USD \n " )) print ( " \n Your Available Options Are: \n " ) [ print (currency) for currency in currencyDict.keys()] nameOfCurrency = input ( " \n Enter The Name Of Currency You Want To Convert Into " "From The Above Available Options \n " ) print ( f" { amount } USD Is Equal To { amount * float (currencyDict[nameOfCurrency]) } " f" { nameOfCurrency } " )

Search Engine

  def matching (userSentence, givenSentence, match ): userSentence = userSentence.split() givenSentence = givenSentence.split() for word1 in userSentence: for word2 in givenSentence: if word1.lower() == word2.lower(): userList return True if __name__ == '__main__' : Sentences = [ "ULYSSES by James Joyce" , "THE GREAT GATSBY by F. Scott Fitzgerald" , "A PORTRAIT OF THE ARTIST AS A YOUNG MAN by James Joyce" , "LOLITA by Vladimir Nabokov" , "BRAVE NEW WORLD by Aldous Huxley" , "THE SOUND AND THE FURY by William Faulkner" , "CATCH-22 by Joseph Heller" , "DARKNESS AT NOON by Arthur Koestler" , "SONS AND LOVERS by D.H. Lawrence" , "THE GRAPES OF WRATH by John Steinbeck" , "UNDER THE VOLCANO by Malcolm Lowry" , "THE WAY O

Library Project

import time class Library : def __init__ ( self , booksList, libraryName, lendDict = {}): self .booksList = booksList self .libraryName = libraryName self .lendDict = lendDict def displayBook ( self ): for book in self .booksList: print (book, " \n " ) def donateBook ( self ): name = input ( "Enter Your Name \n " ) age = int ( input ( "Enter Your Age \n " )) number = int ( input ( "Enter Your Mobile Number \n " )) userInputForBook = input ( "Enter The Name Of The Book \n " ) userInputForAuthor = input ( "Enter The Name Of The Author \n " ) self .booksList.append( f" { userInputForBook } by { userInputForAuthor } " ) with open ( "DonatedBooks.txt" , "a" ) as f2: currentTime = time.asctime(time.localtime(time.time())) f2.write( f" \n\n Name : { name }\n Age :

Health Management System

  # This Is The Python  Code For Health Management System Which Take Cares Of  The Diet And Exercise Of Person.  import  time userinput = int ( input ( "Press \n 1 For Brock \n 2 For Roman \n 3 For Dean \n " )) if userinput == 1 : print ( "Do You Want Log Or Retrieve ?" ) userinputforbrock = int ( input ( "Press \n 1 For Log \n 2 For Retrieve \n " )) if userinputforbrock == 1 : print ( "What Do You Want To Log For Brock ?" ) userinputforlog = int ( input ( "Press \n 1 For Diet \n 2 For Exercise \n " )) timevar = time.asctime(time.localtime(time.time())) if userinputforlog == 1 : userinputfordiet = str ( input ( "Add Diet Food \n " )) f1 = open ( "Diet For Brock.txt" , "a" ) f1.write(timevar) f1.write( " - " ) f1.write(userinputfordiet) f1.write( " \n " ) print (

Guess The Number

  # Guess The Number """This Is The Game In Which You Have To Guess The Number Which Is Hidden In The Code, If You Guess It Correctly You Will Win The Game.""" print ( " * Let's Play The Game Of Guessing The Number * \n " ) print ( "No. Of Guesses Is Limited Only To 9 \n " ) #Initializing No. Of Guesses numberofguesses = 9 #Conditions while numberofguesses > 0 : userinput = int ( input ( "Guess The Number \n " )) if userinput < 10 : print ( "No,The Number Is Greater Than Your Input! Please Guess Again." ) numberofguesses = numberofguesses - 1 print ( "Number Of Guesses Remaining =" ,numberofguesses, " \n " ) if 10 < userinput < 18 : print ( "No,The Number Is Little Greater Than Your Input! Please Guess Again." ) numberofguesses = numberofguesses - 1 print ( "Number Of Guesses Remain

Magic Square

  # Write A Python Program For Magic Square. # A Magic Square Is An n x n Matrix Of The Integers 1 to n^2 Such That The Sum Of Each Row, # Column And Diagonal Is The Same. # The Figure Given Below Is An Example Of Magic Square For Case n = 5. # In This Example, The Example, The Common Sum Is 65. # [[ 9. 3. 22. 16. 15.] # [ 2. 21. 20. 14. 8.] # [ 25. 19. 13. 7. 1.] # [ 18. 12. 6. 5. 24.] # [ 11. 10. 4. 23. 17.]] import numpy as np n = int ( input ( "Enter The Value Of n \n " )) arr = np.zeros([n, n]) row = int (n / 2 ) column = int (n - 1 ) arr[row, column] = 1 row = row - 1 column = column + 1 for val in range ( 2 , n*n + 1 ): if row == - 1 and column == n: row = 0 column = n - 2 arr[row, column] = val elif row == - 1 : row = n - 1 arr[row, column] = val elif

Faulty Calculator

  #Faulty Calculator Which Will Give Wrong Output For 44+5 , 64-9 , 24*8 and 88/6 #Initializing Variables For Operator And Numbers #Try Except Are Used For Exception Handling try : First_Number = int ( input ( "Enter The First Number \n " )) Second_Number = int ( input ( "Enter The Second Number \n " )) Operator = input ( "Select Operator \n + \n - \n * \n / \n % \n // \n ** \n " ) #Conditions if Operator == "+" : if (First_Number == 44 and Second_Number == 5 ) or (First_Number == 5 and Second_Number == 44 ): print ( "Answer = 54" ) else : print ( "Answer =" ,First_Number + Second_Number) elif Operator == "-" : if First_Number == 64 and Second_Number == 9 : print ( "Answer = 49" ) else : print ( "Answer =" ,First_Number - Second_Number) elif Operator == "*" : if (First_Number =