Blog

Follow our blog and get to know about the latest updates in the fields of technology like Python, Machine Learning, Data structures, Data Science, Digital Marketing etc.

Five Interesting Tasks to Automate with Python

22.06.2021

As an individual we have a lot of work to do daily out of which some are repetitive in nature, some are not. What if we tell you that you can actually knock off your repetitive tasks in no time. You just need Python.

Python is an incredibly powerful and flexible open-source language that is used almost everywhere: from web development to game development, from artificial intelligence to data science, from image processing to text processing, from software development to operating systems, and much more. 

Because of its flexibility, and versatility – extended by its extensive library – Python is an amazing tool. You can use Python to automate all your repetitive tasks and focus on those tasks which need our attention. 

Let’s have a look at five Interesting Python-automated tasks:


    1. Task Reminder

    You may use the script below to set a reminder on your Mac or windows.

    First, import the following dependency.

    import time

    Then, in the command line, write code:

    print("What shall I remind you about?")

    text = str(input())

    print("In how many minutes?")

    local_time = float(input())

    local_time = local_time * 60

    time.sleep(local_time)

    print(text)


      2. Language Translator

      You may use the script below to install on your Mac or windows.

      pip install translate

      Then, in the command line, write code:

      # English to German

      from translate import Translator

      translator= Translator(to_lang="German")

      translation = translator.translate("Good Morning!")

      print translation


      # Between Any Two Languages

      from translate import Translator

      translator= Translator(from_lang="german",to_lang="spanish")

      translation = translator.translate("Guten Morgen")

      print translation


        3. Converting Currencies

        All we have to do now is install the library as shown below.

        pip install --user currencyconverter

        This installation should add a currency converter to our $PATH, allowing us to perform a conversion by simply typing the following, as shown in the example.

        currency_converter 1 USD --to EUR


          4. Sending Emails

          All we have to do now is import the library as shown below.

          import smtplib

          Then, in the command line, write code:

          s = smtplib.SMTP('smtp.gmail.com', 587)

          s.starttls()

          s.login("sender_email_id", "sender_email_id_password")

          # message to be sent

          message = "Message_you_need_to_send"

          # sending the mail

          s.sendmail("sender_email_id", "receiver_email_id", message)

          s.quit()


            5. Basic calculator

            In day to day life, calculation is everywhere so based on the user input, we can perform basic arithmetic operations such as addition, subtraction, multiplication, and division.

            Then, in the command line, write code:

            # Function to add two numbers 

            def add(num1, num2):

                return num1 + num2

              

            # Function to subtract two numbers 

            def subtract(num1, num2):

                return num1 - num2

              

            # Function to multiply two numbers

            def multiply(num1, num2):

                return num1 * num2

              

            # Function to divide two numbers

            def divide(num1, num2):

                return num1 / num2

              

            print("Please select operation -\n" \

                    "1. Add\n" \

                    "2. Subtract\n" \

                    "3. Multiply\n" \

                    "4. Divide\n")  

              

            # Take input from the user 

            select = int(input("Select operations form 1, 2, 3, 4 :"))

            number_1 = int(input("Enter first number: "))

            number_2 = int(input("Enter second number: "))

              

            if select == 1:

                print(number_1, "+", number_2, "=",

                                add(number_1, number_2))

              

            elif select == 2:

                print(number_1, "-", number_2, "=",

                                subtract(number_1, number_2))

              

            elif select == 3:

                print(number_1, "*", number_2, "=",

                                multiply(number_1, number_2))

              

            elif select == 4:

                print(number_1, "/", number_2, "=",

                                divide(number_1, number_2))

            else:

                print("Invalid input")



            Conclusion

            Python is a powerful language that will make you more productive and efficient the more you study and practice it. We are really happy to share these interesting automation tasks with you, and we hope you find them useful and interesting as well.