Explore

Python Programs

Love Calculator In Python With Source Code

Love Calculator In Python With Source Code

Want to know how to create love calculator program in python, then you are at the right place today in this tutorial. I will show you how to create love calculator in python with source code.

When I was in school students used to remove love percentage of a boy and a girl by using some calculations so I have decided to create this python program for love calculator.

I have created this program using conditions like length, first and last character match of both the persons name you can add more conditions you like in this program.

Python Code For Love Calculator


print("Welcome to python love calculator program")

p1 = input("What is the name of person 1 : ")
p2 = input("What is the name of person 2: ")

len1 = (len(p1))
len2 = (len(p2))

len_p = 20 if len1 == len2 else 5
first_char = 50 if p1[0] == p2[0] else 5
last_char = 30 if p1[len1 - 1] == p2[len2 - 1] else 5

percentage =  len_p + first_char + last_char
 
print(f"Your love is {percentage}% true")

Above is the python program to calculate love. Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer.

To run this python program, follow the below steps:

  • Create a new folder for this python project.
  • Open it in a code editor of your choice.
  • Create a python file with an ending .py extension.
  • Copy the above code and paste it in your file.
  • Open a terminal or CMD at folder location
  • And type this command python filename.py (Name of your file).

After running this program you will see that it asks you to enter your and your partner name then according to the conditions it will calculate and print the percentage of your love below is an example output.


Welcome to python love calculator program
What is the name of person 1 : mary
What is the name of person 2: mario
Your love is 60% true

As you can see we successfully created this program in python. Don’t want to create all the files and folders then you can run this program now using this online python compiler.

Summary

This was a simple love calculator program in python. I hope you found this tutorial helpful and useful. Do share this tutorial with your friends who might need this program.

Here are some more python program tutorials for you:

I hope you found what you were looking for from this tutorial, and if you want more python programs and tutorials like this, do join our Telegram channel for future updates.

Thanks for reading, have a nice day 🙂