Sunday 20 March 2022

Python # 10 : IF( COMPATIBILITY OF MARRIED COUPLES).

IF ..ELSE ..IF (again)

Let us have fun!. 

We see the married couple are compatible or not in Python?

Syntax for IF clause is very super simple.

Python supports the usual logical conditions from mathematics:

  • Equals: a == b
  • Not Equals: a != b
  • Less than: a < b
  • Less than or equal to: a <= b
  • Greater than: a > b
  • Greater than or equal to: a >= b

These conditions can be used in several ways, most commonly in "if statements" and loops.

A simple IF statement.

if a>10:

    print('a is greater than 10')

else:

    print('Not greater than 10)


if CONDITION1:

   do something
elseif CONDITION2:
   do this thing:
else:
        do unsatisfied condition things

How it can for us to see the couple's Compatibility! hey .. wait .. wait.. wait..

Ask the names of couples

Check whether their names consists of letters T, R,U, E, L,O,V, E

count those letters

if sum >50, they are absolutely compatible. or not.!

let us code this as follows:


name1 = input("Enter Husband Name ").lower()
name2 = input("Enter Wife's Name ").lower()
Total_TRUE = name1.count('t') + name2.count('t') + name1.count('r') + name2.count('r') + name1.count('u') + name2.count('u') + name1.count('e') + name2.count('e')
A = str(int(Total_TRUE))
Total_LOVE = name1.count('l') + name2.count('l') + name1.count('o') + name2.count('o') + name1.count('v') + name2.count('v') + name1.count('e') + name2.count('e')
B = str(int(Total_LOVE))
score = int(A + B)

if score < 10 or score >90:
print(f"Your score is{score}%, you go together like coke and mentos.")
elif score >40 and score < 50:
print(f"Your score is {score}%, you are alright together")
else:
print(f"Your score is {score}% Compatible")

Result:  Suppose if I give two names like DHANUSU and ISHU


Enter Husband Name DHANUSU
Enter Wife's Name ISHU
Your score is 30% Compatible

Process finished with exit code 0

Python says these names are less compatible.

Hooray, Python found out the reason for Divorce?😄 No  fault of Individuals !!!👨👩


1 comment:

  1. Sir, python coding is really lucid and easy to understand even from a layman point of view who doesn't have any coding experience. Tx

    ReplyDelete

Making Prompts for Profile Web Site

  Prompt: Can you create prompt to craft better draft in a given topic. Response: Sure! Could you please specify the topic for which you...