Posts

Automate your file manager using Python

 Code: import  os  # imports os module  import  shutil  # imports shutil module file =os.listdir()  # it lists the files present in this directory  def   Createfolder ( foldername ):  # Creates a foldername with a provided name      if   not  os.path.exists(foldername): # if folder does not exists          os.makedirs(foldername)  # Then folder gets created of provided foldername      else :          print ( f " { foldername }  folder already exists" )  #if folder exists message gets printed   Createfolder( 'Media' ) Createfolder( 'Documents' ) Createfolder( 'Others' )   # c...

Grab latest technology news by just writing nine lines of code in "Python"!

Image
I n today's era who would don't like to learn about technology? .The latest trending hot topics like Machine learning, Data Science, Big data,  and  Data visualization. these are such technologies that are taking the world to the next level.  The person who might be reading this may be a computer nerd or expert or a student like me. So to be updated we must read the treading topics of upcoming updates and technology But I know you very well!. Going to the website or reading articles or even in-shorts sounds troublesome. So the best and fun solution is that we can read the news programmatically. To do this I have used the requests module and JSON module Here the major part is to get the API key by creating an account on the  news API website . requests. get(URL) -- it visits the provided URL and collects the HTML content of the web page brings it in the python code. But we need the title from the news  So to do that, I have used JSON built-in function JSON.l...

Grab repeated Strings from any given sentences

Image
  Code: For extracting repeated string occurrences def   Occurrences ( string ):     word= "Microsoft"     letters={words  for  words  in  string  if  words  in  word.lower()}        print ( f " { '' .join(letters).upper() } \n Repeated letters:  { len (letters) } " ) Occurrences( input ( "Enter the letters " ))

Generate a Bill receipt using Python

Image
   Code for The receipt generator:  rate= 0 while   True :      try :         amount= input ( "Enter the rate " )          if  amount== "q" :              with   open ( "Bill.txt" , "a" )  as  files:                 files.write( f "Bill: { rate } \n " )                  break          else :             rate=rate+ int (amount)      except :          print ( "Please enter a valid input" )

Train ticket booking project using Python

Image
  I am using Visual studio code editor for this project. Its really awesome for writing  huge programs as it has awesome extensions which makes your coding life ease. It has triggered love for many coders as it is one of the  Microsoft Produ ct. Link for vs code:  Visual studio code Feel free to use other editors   Like pycharm . B ut for my convince I am using VS Code. The Project begins with importing some required modules by using "import"  keyword.  Datetime  Random Datetime Module : This module is used to fetch the current time and date as the name suggests. I have used "datetime.datetime.now()"  for Bookticket function to do this task. Random Module:  This module is used to generate a random number. For more checkout the documentation   Random module Strftime: It used to convert time into string. For more details checkout the documentation:  Strftime To create a class use the keyword  class : A class is a Te...